#include<reg51.h>
#include"lcd_display.h"
sbit ON = P1^0;
sbit floor1 = P1^1;
sbit floor2 = P1^2;
sbit floor3 = P1^3;
sbit dooropen = P1^4;
sbit motorF = P2^0;
sbit motorR = P2^1;
sbit motor_en = P2^3;
sbit led_doorOpen = P2^2;
sbit ON_led = P2^4;
void delay_sec(int);
short int PresentLevel = 0, RequestLevel;
void main()
{
motorF = motorR = led_doorOpen = motor_en = ON_led = rs = en = 0;
ON = floor1 = floor2 = floor3 = dooropen = 1;
TMOD = 0x01;
P3=0x00;
lcd_init();
motor_en=0;
while(1)
{
while(!ON)
{
ON_led=1;
lcd_cmd(0x01);
lcd_dataS("welcome");
lcd_cmd(0xc0);
lcd_dataS("present floor-");
lcd_dataint(PresentLevel);
while(floor1==1 && floor2==1 && floor3==1 && dooropen==1);
//wait till any option is pressed
if(dooropen==0) // if door is opened
{
while(floor1==1 && floor2==1 && floor3==1);
//wait for user option(now you are in the lift)
if(floor1==0)
RequestLevel=1; //used to store the respective option
if(floor2==0)
RequestLevel=2;
if(floor3==0)
RequestLevel=3;
}
if(floor1==0) //this is when pressing outside the lift
RequestLevel=1;
if(floor2==0)
RequestLevel=2;
if(floor3==0)
RequestLevel=3;
lcd_cmd(0x01);
lcd_dataS("Requested f");
lcd_dataint(RequestLevel);
while(PresentLevel < RequestLevel)
{
motor_en=1; //if presentlevel is less than requestlevel
motorF=1; // turn motor in forward direction
motorR=0;
delay_sec(5);
lcd_cmd(0xc0);
PresentLevel++;
lcd_dataS("PresentLevel-");
lcd_dataint(PresentLevel);
}
motor_en=0;
while(PresentLevel > RequestLevel)
{
motor_en=1; //if presentlevel is greater then requestL
motorF=0; //turn motor in REVERSE direction
motorR=1;
delay_sec(5);
PresentLevel--;
lcd_cmd(0xc0);
lcd_dataS("PresentLevel-");
lcd_dataint(PresentLevel);
}
motor_en=0;
if(PresentLevel==RequestLevel)
{
led_doorOpen=1;
lcd_cmd(0x01);
lcd_dataS("level reached");
lcd_cmd(0xc0);
lcd_dataS("door opened ");
delay_sec(10);
led_doorOpen=0;
}
}
ON_led=0;
}
}
void delay_sec(int x)
{
int i = 0,j;
for(i = 0;i
{
for(j = 0;j<14;j++)
{
TR0 = 1;
while(TF0 != 1);
TF0 = 0;
TR0 = 0;
}
}
}
Saturday, February 25, 2012
Simple ELEVATOR program for 8051
Subscribe to:
Post Comments (Atom)
very nice but no digram
ReplyDeletenice post
ReplyDeletewe are hospital lift service providers in delhi
goods lift manufacturers in delhi
glass lift service providers in delhi
these looks are pretty interesting.
ReplyDeleteGoods Lift Manufacturers in Bangalore | Hydraulic Goods Lift Manufacturers in Bangalore