Handheld Vehicle Lock Control System Using Wireless Communication (IR / RF)

CODING:
/**COMPILER DIRECTIVES**/
#include
/**PORT DEFINATIONS**/
#define LCD P0
sbit ir=P3^3;
/**FUNCTIONS DECLARATION**/
void lcd_init(void);
void lcd_cmd(unsigned char);
void lcd_data(unsigned char);
void lcd_str(unsigned char *);
void integer_LCD(int);
void delay_ms(unsigned int);
/**GLOBAL VARIABLE DECLARATION**/
unsigned char i,bitCount;
sbit buzzer = P2^0;
sbit M1 = P2^3;
sbit M2 = P2^4;
/**MAIN FUNCTION**/
void main()
{
/**VARIABLES DECLARATION**/
char addr,cmd,mul;
buzzer = 0;
M1 = M2 = 0;
lcd_init(); //LCD INITIALIZATION
lcd_cmd(0×80); //1ST LINE DISPLAY
lcd_str(“St.JOHNS COLLEGE”); //STRING DISPLAY
lcd_cmd(0xC0); //1ST LINE DISPLAY
lcd_str(“**Dept. Of ECE**”); //STRING DISPLAY
delay_ms(500);
lcd_cmd(0×01);
lcd_cmd(0×80); //1ST LINE DISPLAY
lcd_str(“RC5 Protocol”); //STRING DISPLAY
lcd_cmd(0xC0); //1ST LINE DISPLAY
lcd_str(“DOOR = CLOSE “); //STRING DISPLAY
M1 = 0;
M2 = 1;
buzzer = 1;
delay_ms(10);
M1 = M2 = 0;
buzzer = 0;
while(1)
{
addr=0×00,cmd=0×00; //VARIABLES INITIALIZATION
while(ir); //WAITING FOR INTERRUPT
mul=0×10;
for(i=255;i>0;i–); ////wait for first three bits
for(i=255;i>0;i–);
for(i=255;i>0;i–);
for(i=255;i>0;i–);
for(i=255;i>0;i–);
for(i=255;i>0;i–);
for(i=25;i>0;i–);
for(i=114;i>0;i–);
for(bitCount=0;bitCount<5;bitCount++) { for(i=255;i>0;i–); //capture bit address data in pre defined time
for(i=255;i>0;i–);
for(i=255;i>0;i–);
for(i=4;i>0;i–);
if(!ir)
addr|=mul;
mul/=2;
}
mul=0×20;
for(bitCount=0;bitCount<6;bitCount++) { for(i=255;i>0;i–); //capture bit command data in pre defined time
for(i=255;i>0;i–);
for(i=255;i>0;i–);
for(i=4;i>0;i–);
if(!ir)
cmd|=mul;
mul/=2;
}
if(cmd == 12)
{
lcd_cmd(0×80);
lcd_str(” RIGHT COMMAND “);
M1 = 1;
M2 = 0;
buzzer = 1;
delay_ms(10);
M1 = M2 = 0;
buzzer = 0;
lcd_cmd(0xc0);
lcd_str(“DOOR : OPEN “);
}
else if(cmd == 34)
{
lcd_cmd(0×80);
lcd_str(” RIGHT COMMAND “);
M1 = 0;
M2 = 1;
buzzer = 1;
delay_ms(10);
M1 = M2 = 0;
buzzer = 0;
lcd_cmd(0xc0);
lcd_str(“DOOR : CLOSE “);
}
else
{
lcd_cmd(0×80);
lcd_str(” WRONG COMMAND “);
lcd_cmd(0xc0);
lcd_str(“ “);
}
}
}
/**LCD INITIALIZATION FUNCTION**/
void lcd_init(void)
{
lcd_cmd(0×28);
lcd_cmd(0x0C);
lcd_cmd(0×06);
lcd_cmd(0×01);
}
/**LCD COMMAND FUNCTION**/
void lcd_cmd(unsigned char c)
{
LCD=((c & 0xf0) | 0×08);
LCD=0;
LCD=(((c & 0x0f)<<4)|0×08); LCD=0; delay_ms(2); } /**LCD DATA FUNCTION**/ void lcd_data(unsigned char c) { LCD=((c&0xf0)|0x0A); LCD=0; LCD=(((c & 0x0f)<<4)|0x0A); LCD=0; delay_ms(2); } /**LCD STRING FUNCTION**/ void lcd_str(unsigned char *s) { while(*s) lcd_data(*s++); } /**MILLI SECONDS DELAY**/ void delay_ms(unsigned int i) { unsigned int j; while(i–>0)
for(j=1000;j>0;j–);
}

Want to build your own robot? Check out these robotics products and kits that you can use to get started on building a bot, either totally from scratch or by using a kit.


27 Responses to “Handheld Vehicle Lock Control System Using Wireless Communication (IR / RF)”

  1. sushmita

    i need the god damn code of pc operation control using ir remote

    Reply

Leave a Reply