Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Complete Sensor Guide
      • Engineering Deep Dives
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Tech Terms
    • Webinars & Digital Events
  • Resources
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • White Papers
  • Guest Post Guidelines
  • Advertisers
    • Advertise
    • PR Submissions
    • Eblast Submissions
  • Subscribe

Lift Overload Indicator

By Jimit Kavathia April 21, 2008

 

Embedded Systems are widely used nowadays. Applications of the embedded system are innumerable. One such application as discussed here is Lift Overload Indicator. As the name implies, it restricts the elevator from transporting a number of people above the maximum prescribed limit.
The indicator used here is RGB led to indicate the warning signs. Moreover, it also displays the net number of people in the elevator using an LCD in 4-bit mode. The counting of the person is accomplished by using two IR sensors.
Prototype of AVR ATMega16 based Lift Overload Indicator
Fig. 1: Prototype of AVR ATMega16 based Lift Overload Indicator
DESCRIPTION:
RGB LED:
We know that using the three primary colours Red, Blue and Green, any secondary colour can be obtained. The RGB led uses the same principle. Different colours are generated by mixing of different intensities of the three primary colours.
Image showing pin description of RGB LED
Fig. 2: Image showing pin description of RGB LED
It has got four pins viz., Red supply, Blue supply, Green supply and Ground. The intensities of each of these colours are controlled using PWM (Pulse Width Modulation). The contribution of intensities of each of this colour determines the resultant colour in RGB led and it glows accordingly. The function for RGB led is written below. The RGB pins are controlled using three timers offered by ATmega16, particularly Timer0 and Timer1. Refer to my last article for more information on timers.
void rgb_led(unsigned char red ,unsigned char green, unsigned char blue)
{
OCR0=((255*blue)/100);                   //Output Compare Match Value for Blue Led
OCR1A=((255*green)/100);              //Output Compare Match Value for Green Led

OCR1B=((255*red)/100);                  //Output Compare Match Value for Red Le

}
As shown above, we have used three different PWM for controlling intensity of each colour. The 16-bit TIMER-1 is split into two 8-bit timer (OCR1A & OCR1B).
The arguments of the above function are passed in the form of percentage which is then converted into its equivalent PWM. This is explained below with an example:
                        rgb_led(90,50,50);
This will illuminate the red colour by 90%, blue by 50% and green by 50%.The setting of various bits in the TIMER registers is shown below.

// Configure timer 1

TCCR1A=(1<<WGM10);                                          // Fast PWM mode (8-bit) TCCR1A|=((1<<COM1A1)|(1<<COM1B1));          // Reset OCR on Compare Output Match TCCR1B=(1<<WGM12);// Fast PWM mode (8-bit) TCCR1B|=(1<<CS11);                
// Prescaler set to 1/8 DDRD=((1<<PD4)|(1<<PD5)); // OCR1A and OCR1B set as output pins
// Configure timer 0
TCCR0|=((1<<WGM01)|(1<<WGM00));   // FAST PWM mode    TCCR0|=(1<<COM01);                                                       
// set OCR0 on match TCCR0|=(1<<CS01); // pre-scaler set to 1/8; DDRB|=1<<PB3;                                                                        // OCR0 set as output pin
LCD:
The LCD is used to display the number of persons inside the elevator at any point of time. The LCD is used in 4-bit mode .Refer to my last article for better understanding of the LCD. I have used a new function which passes string type argument to the LCD.
void lcd_string (char *z)  // To display string on LCD

{   unsigned char i=0;

 

 while (z[i]!=’’)

 

    { lcd_data(z[i]);

 

   i++;

 

if (i==15)  //If the string is greater than 14 characters,
  { lcd_cmd(0xc0);                                             //switch to next line

 } } }

 

The subroutine displays each value of the array and then increments the counter ‘i’ to display the next character of the string. The while () loop terminates as soon as the null character ‘’ is passed to the function.
This function is used to display the strings ‘EMPTY’ and ‘OVERLOAD’ which describes the two conditions of the elevator.

Main Function

MAIN FUNCTION:
The main function begins with the initialization of all the port pins used either as input or outputs. It also initialises the LCD and displays the string ‘EMPTY’. The initial status of the RGB led is green in colour. The IR sensors are connected to PA0 and PA1. Hence, these pins are declared as input.
int main()
{            char i=0; // Person Counting variable

 

 DDRC=0XFF;  // LCD-port as Output Port

lcd_int();

 

 timer_int();

 

 lcd_string (“empty”);

_delay_ms (1);

 

 rgb_led (0,90,0);  // initial condition of led

DDRA&=~((1<<IR1)|(1<<IR2));    // IR sensors as input

After initialisation the function enters into infinite while loop where it continuously checks the IR sensors. If IR-1 triggers any output signal, the controller understands that one person has entered and thus increments the counter ‘i’ by one. But if IR-2 triggers the output then the controller manipulates it as one person leaving the elevator and hence decrements the counter by one.

 

while(1)

 {

 if((PINA&(0X01))==0x01)                        // person entering the lift

   {     while((PINA&(0X01)));

                   i++;

check:

          if(i<=safe_value)

           {  lcd_cmd(0x01);

            lcd_data(0x30+i);

          rgb_led(0,95,0);

  }

  else if(i>safe_value && i<=max)

           {  lcd_cmd(0x01);

             lcd_data((0x30+i));

             rgb_led(0,0,95);

           }

else if (i>max )

           {lcd_cmd(0x01);

   lcd_string(“OVERLOADED”);

        rgb_led(90,0,0);

 

           }}

 

 else if((PINA&(0X02))==0x02)                  // person going out , hence

   {     while((PINA&(0X02)));

                   i–;

goto check;

}}

 

 return 0;

}

After the occurrence of event caused by any of the two IR sensors, the function jumps to check the counter‘s (i) value.

Note: The variables ‘safe_value’ and ‘max’ are global variables and denotes the safe number and the maximum number of people which can be carried by the elevator respectively.
If the number is less than the allowable (safe_value) value, the RGB led appears green. If the counter value is between the ‘safe_value’ and the maximum allowable value(max), the led changes to blue. And if the Elevator exceeds the maximum number of people to be carried then it displays Bright red colour and the LCD displays ‘OVERLOAD’.

 

Project Source Code

###

/******************************************** LIFT OVERLOAD INDICATOR ********************/
/* 
	LCD Configurations:
	> LCD data transfer through 4 bit mode
 		
		LCD port----PORT C  
		rs-------PC0
		rw-------PC1
		en-------PC2

RGB-LED Connection:
>Blue Pin is Connected To OCR0
>Green Pin is Connected To OCR1A
>Red Pin is Connected To OCR1B

*/

#include<avr/io.h>
#define F_CPU 8000000UL
#include<util/delay.h>
#define data PORTC
#define rs 0 // Register select Pin
#define rw 1 // Read Write Pin
#define en 2 // Enable Pin
#define IR1 PA0 // IR Sensor-1 (Senses the person entering the elevator)
#define IR2 PA1 // IR Sensor-2 (Senses the person leaving the elevator)
#define safe_value 5
#define max 8

/************************************************* LCD SUB-ROUTINES ***************************/

void lcd_cmd(char x) // To Give Command To Lcd
{

data=0XF0&x; // higher nibble is passed masking the lower nibble

data&=~(1<<rw);

data&=~(1<<rs);

data|=1<<en;

_delay_ms(5);

data&=~(1<<en);

x=x<<4; // shifting lower nibble to higher nibble

data=0XF0&x; // lower nibble is passed masking the higher nibble

data&=~(1<<rw);

data&=~(1<<rs);

data|=1<<en;

_delay_ms(5);

data&=~(1<<en);


}


void lcd_data(char y) // To Read/Write data to LCD
{

data=0XF0&y; // higher nibble

data&=~(1<<rw);

data|=1<<rs;

data|=1<<en;

_delay_ms(5);

data&=~(1<<en);


y=y<<4; // shifting lower nibble to higher

data=0XF0&y; // lower nibble

data&=~(1<<rw);

data|=1<<rs;

data|=1<<en;

_delay_ms(5);

data&=~(1<<en);


}

void lcd_int(void) // To initialize LCD
{

lcd_cmd(0x02); // intialize 5x7 matrix
lcd_cmd(0x0c); // display on, cursor off
lcd_cmd(0x28); // home position
lcd_cmd(0x06); // entry Mode
lcd_cmd(0x01); // clear Lcd
}

void lcd_string(char *z) // To display string on LCD
{
unsigned char i=0;

while(z[i]!='')
{
lcd_data(z[i]);
i++;

if(i==15) //If the string is greater then 14 characters,
{
lcd_cmd(0xc0); //switch to next line
}


}

}


/************************************************* TIMER SUB-ROUTINES *********************/

void timer_int(void) // Timer Iniatialization
{

// Configure timer 1

TCCR1A=(1<<WGM10); // Fast PWM mode (8-bit)
TCCR1A|=((1<<COM1A1)|(1<<COM1B1)); // Reset OCR on Compare Output Match
TCCR1B=(1<<WGM12); // Fast PWM mode (8-bit)
TCCR1B|=(1<<CS11); // Prescaler set to 1/8
DDRD=((1<<PD4)|(1<<PD5)); // OCR1A and OCR1B set as output pins


// Configure timer 0

TCCR0|=((1<<WGM01)|(1<<WGM00)); // FAST PWM mode
TCCR0|=(1<<COM01); // set OCR0 on match
TCCR0|=(1<<CS01); // pre-scaler set to 1/8;
DDRB|=1<<PB3; // OCR0 set as output pin

}

/************************************************* RGB-LED ROUTINE ***************************/

void rgb_led(unsigned char red ,unsigned char green, unsigned char blue)
{

OCR0=((255*blue)/100); //Output Compare Match Value for Blue Led
OCR1A=((255*green)/100); //Output Compare Match Value for Green Led
OCR1B=((255*red)/100); //Output Compare Match Value for Red Led

}

/************************************************* MAIN FUNCTION *************************/

int main()
{
char i=0; // Person Counter

DDRC=0XFF; // LCD-port as Output Port

lcd_int();
timer_int();

lcd_string("empty");
_delay_ms(1);
rgb_led(0,90,0); // intial condition of led


DDRA&=~((1<<IR1)|(1<<IR2)); // IR sensors as input

while(1)
{
if((PINA&(0X01))==0x01) // person entering the lift
{
while((PINA&(0X01)));
i++;

check:

if(i<=safe_value)
{
lcd_cmd(0x01);
lcd_data(0x30+i);
rgb_led(0,95,0);
}

else if(i>safe_value && i<=max)
{
lcd_cmd(0x01);
lcd_data((0x30+i));
rgb_led(0,0,95);
}

else if (i>max )
{
lcd_cmd(0x01);
lcd_string("OVERLOADED");
rgb_led(90,0,0);
}
}


else if((PINA&(0X02))==0x02) // person going out , hence
{
while((PINA&(0X02)));
i--;
goto check;
}

}

return 0;

 

 

 

 

 


 

###

 


Circuit Diagrams

Circuit-Diagram-AVR-ATMega16-Based-Lift-Overload-Indicator

Project Video


Filed Under: Electronic Projects
Tagged With: indicator, lift
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

Log in to leave a comment:

Lost your password?

Don't have an account? Register here

Submit a Guest Post

submit a guest post

EE TECH TOOLBOX

“ee
Tech Toolbox: Wide Bandgap Semiconductors
Moving from silicon to GaN or SiC feels like a whole new ballgame, doesn’t it? It isn’t just about faster switching; it’s about managing the layout parasitics and thermal realities that come with that speed. This month’s Tech Toolbox features a curated eBook that tackles these design hurdles head-on.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS feed: EDABOARD.com Discussions. EDABOARD.com Discussions.

  • SMPS PCB Layout: High di/dt traces.
  • Altium is hanging and slow after Protel import?
  • voltage amplifier for a signal generator
  • PCB not properly made
  • Arduino-based line follower robot

RSS feed: Electro-Tech-Online.com Discussions Electro-Tech-Online.com Discussions

  • Ways of handle battery when reaching charge
  • PIC Assembler Coding
  • Jumper Wire Assortment From Digikey
  • How to charge 3S1P LFP batteries?
  • Best way to check charge and discharge many mixed batteries?

Featured Tutorials

LoRa and LoRaWAN: A Complete Guide to Wireless Communication

  • Best practices for securing LoRa networks
    Best practices for securing LoRa networks
  • Understanding LoRa architecture: nodes, gateways, and servers
    Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
    Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
    How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication
    How LoRa enables long-range communication
  • How communication works between two LoRa end-node devices
    How communication works between two LoRa end-node devices
More Tutorials >

Recent Articles

  • Emerson adds 1.5 GHz oscilloscopes and 6½-digit DMM
  • TASKING introduces unified toolchain for automotive multicore processors
  • Harwin launches custom cable assembly and testing service
  • Renesas introduces 64-bit MPU for four-axis motor control
  • STMicroelectronics GaN drivers handle 60 A in compact LGA

EE ENGINEERING TRAINING DAYS

engineering
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2026 Arrowfly LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of Arrowfly
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Complete Sensor Guide
      • Engineering Deep Dives
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Tech Terms
    • Webinars & Digital Events
  • Resources
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • White Papers
  • Guest Post Guidelines
  • Advertisers
    • Advertise
    • PR Submissions
    • Eblast Submissions
  • Subscribe