#include <REGX51.H>
#include "lcd.c"
#define MAX_DELAY() delay(65000)
sbit one=P1^0;
sbit two=P1^1;
sbit three=P1^2;
sbit four=P1^3;
sbit Rly1=P0^0;
sbit Rly2=P0^1;
void intro()
{
lcd_init();lcd_clr();
lcd_str("8051 based Lamp ",0x80);
lcd_str("Dimmer-TouchPlat",0xc0);
MAX_DELAY();MAX_DELAY();
lcd_clr();
}
//void convert_to_Binary(unsigned char num)
//{
// unsigned char temp = 0, i;
// for(i=0;i<8;i++)
// {
// temp = num & 0x80;
// num = num << 1;
// lcd_data((temp == 0) ? '0' : '1');
// }
//}
void main()
{
unsigned int i = 0, j= 0, cntr = 0;
// unsigned char port_val;
Rly1 = Rly2 = 0;
intro();
while(1)
{
lcd_str("Touch any Button ",0x80);
// port_val = P1;
// lcd_str("P1:",0xc0);
// convert_to_Binary(port_val);
// delay(65000);
// while(port_val == P1);
while((one == 1) && (two == 1) && (three == 1) && (four == 1))
delay(10000);
if(one == 0)
{
cntr = 65000;
while((one == 0) && (--cntr));
if(cntr <= 0)
{
lcd_str("1 -> Lamp On ",0xc0);
Rly1 = 1; Rly2 = 0;
while(one == 0);
}
}
else if(two == 0)
{
cntr = 65000;
while((--cntr) && (two == 0));
if(cntr <= 0)
{
lcd_str("2 -> Lamp Dimm ",0xc0);
Rly1 = 1; Rly2 = 1;
while(two == 0);
}
}
else if(three == 0)
{
cntr = 65000;
while((--cntr) && (three == 0));
if(cntr <= 0)
{
lcd_str("3 -> Lamp Off ",0xc0);
Rly1 = 0; Rly2 = 0;
while(three == 0);
}
}
}
}
#include "lcd.c"
#define MAX_DELAY() delay(65000)
sbit one=P1^0;
sbit two=P1^1;
sbit three=P1^2;
sbit four=P1^3;
sbit Rly1=P0^0;
sbit Rly2=P0^1;
void intro()
{
lcd_init();lcd_clr();
lcd_str("8051 based Lamp ",0x80);
lcd_str("Dimmer-TouchPlat",0xc0);
MAX_DELAY();MAX_DELAY();
lcd_clr();
}
//void convert_to_Binary(unsigned char num)
//{
// unsigned char temp = 0, i;
// for(i=0;i<8;i++)
// {
// temp = num & 0x80;
// num = num << 1;
// lcd_data((temp == 0) ? '0' : '1');
// }
//}
void main()
{
unsigned int i = 0, j= 0, cntr = 0;
// unsigned char port_val;
Rly1 = Rly2 = 0;
intro();
while(1)
{
lcd_str("Touch any Button ",0x80);
// port_val = P1;
// lcd_str("P1:",0xc0);
// convert_to_Binary(port_val);
// delay(65000);
// while(port_val == P1);
while((one == 1) && (two == 1) && (three == 1) && (four == 1))
delay(10000);
if(one == 0)
{
cntr = 65000;
while((one == 0) && (--cntr));
if(cntr <= 0)
{
lcd_str("1 -> Lamp On ",0xc0);
Rly1 = 1; Rly2 = 0;
while(one == 0);
}
}
else if(two == 0)
{
cntr = 65000;
while((--cntr) && (two == 0));
if(cntr <= 0)
{
lcd_str("2 -> Lamp Dimm ",0xc0);
Rly1 = 1; Rly2 = 1;
while(two == 0);
}
}
else if(three == 0)
{
cntr = 65000;
while((--cntr) && (three == 0));
if(cntr <= 0)
{
lcd_str("3 -> Lamp Off ",0xc0);
Rly1 = 0; Rly2 = 0;
while(three == 0);
}
}
}
}
Comments
Post a Comment