Free online courses with Free Certificate
Keil c51:
DevC++ compiler(or IDE)
Download link: Click here
step-1: right click on "Keil uvision" and click on "run as administrator"
step-2: now go to project >> new project >> "project_name.uvproj"
step-3: select "at89c51" as shown below
step-3: now file >> new file
step-4: click on save as then save with "file_name.c" i.e. with ".c" extension
step-5: now copy code given below and paste and save it, as shown below
step-6: to the left side of window right click on "Source group 1" and then click on "add existing file to source group 1"
step-7: now click on project >> build target to compile this code i.e. to check if any error in code
step-8: to generate "hex file" of this code right click on "target 1" tab to the left side of your window and then click on "options for target 'target 1'... " as shown below
step-9: now change frequency to "11.0592MHz" and tick to "use on-chip ROM" as shown below
step-10: now in same window options click on output >> tick to "create hex file" as shown below
step-11: click again on "build target" to create "hex file" as shown below
Embedded C code :
Code with comments for understanding
#include<reg51.h>
//for in-out car
sbit doorp=P2^0; //clockwise rotation
sbit doorn=P2^1; //anticlockwise rotation
//for display
sbit rs=P2^5; //reg select fun of lcd
sbit rw=P2^6; //read write fun of lcd
sbit en=P2^7; //enable fun of lcd
//lcd functions
void lcddat(unsigned char); //dat fun of lcd
void lcdcmd(unsigned char); //command fun of lcd
void lcddis(unsigned char *); //display fun of lcd
void lcd_init(); //iniialization of lcd
void serial_init(); //write serial comm steps betwn rfid and uc
void check(); //to compare person in existing dat or outside dat
void delay(); //for lcd
void mdelay(); //for motor
unsigned char rfid[12],v1; //rfid 12 byte siz tag
void main()
{
doorp=doorn=0; //motor stop
serial_init();
lcd_init();
lcddis("RFID BASED CAR");
lcdcmd(0xc0); //cursor shit on second line
lcddis("PARKING SYSTEM");
mdelay();
lcdcmd(0x01);
while(1)
{
lcdcmd(0x01);
lcddis("SWIPE YOUR CARD");
for(v1=0;v1<12;v1++) //this loop is to read 12 digits of rfid card
{
while(RI==0); //if RI=1 dat is ready in sbuf
rfid[v1]=SBUF;
RI=0;
SBUF=rfid[v1]; //next 3 lines are for re-tx of chr to simulate on proteus
while(TI==0);
TI=0;
}
check(); //to compare person in existing dat or outside dat
}
}
void check()
{
//RFID TAG OF BARAK OBAMA-35858VUET8G8
if(rfid[0]=='3'&&rfid[1]=='5'&&rfid[2]=='8'&&rfid[3]=='5'&&rfid[4]=='8'&&rfid[5]=='V'&&rfid[6]=='U'&&rfid[7]=='E'&&rfid[8]=='T'&&rfid[9]=='8'&&rfid[10]=='G'&&rfid[11]=='8')
//if loop for comparing rfid tag positions from 0 to 7 with respective number as given above
{
lcdcmd(0x01);
lcddis("TEAM MEMBER");
lcdcmd(0xc0);
lcddis("OBAMA-SLOT 1");
mdelay();
lcdcmd(0x01);
doorp=1;
doorn=0;
lcddis("OPENING DOOR");
lcdcmd(0xc0);
lcddis("PLEASE GO INSIDE");
mdelay();
doorp=0;
doorn=0;
lcdcmd(0x01);
doorp=0;
doorn=1;
lcddis("CLOSING DOOR");
mdelay();
doorp=0;
doorn=0;
}
//RFID TAG OF JOE BIDEN-4WRF723RF24F
else if(rfid[0]=='4'&&rfid[1]=='W'&&rfid[2]=='R'&&rfid[3]=='F'&&rfid[4]=='7'&&rfid[5]=='2'&&rfid[6]=='3'&&rfid[7]=='R'&&rfid[8]=='F'&&rfid[9]=='2'&&rfid[10]=='4'&&rfid[11]=='F')
//if loop for comparing rfid tag positions from 0 to 7 with respective number as given above
{
lcdcmd(0x01);
lcddis("TEAM MEMBER");
lcdcmd(0xc0);
lcddis("BIDEN-SLOT 2");
mdelay();
lcdcmd(0x01);
doorp=1;
doorn=0;
lcddis("OPENING DOOR");
lcdcmd(0xc0);
lcddis("PLEASE GO INSIDE");
mdelay();
doorp=0;
doorn=0;
lcdcmd(0x01);
doorp=0;
doorn=1;
lcddis("CLOSING DOOR");
mdelay();
doorp=0;
doorn=0;
}
//RFID TAG OF GEORGE BUSH JR-5F8344FN9229
else if(rfid[0]=='5'&&rfid[1]=='F'&&rfid[2]=='8'&&rfid[3]=='3'&&rfid[4]=='4'&&rfid[5]=='4'&&rfid[6]=='F'&&rfid[7]=='N'&&rfid[8]=='9'&&rfid[9]=='2'&&rfid[10]=='2'&&rfid[11]=='9')
//if loop for comparing rfid tag positions from 0 to 7 with respective number as given above
{
lcdcmd(0x01);
lcddis("TEAM MEMBER");
lcdcmd(0xc0);
lcddis("BUSH JR-SLOT 3");
mdelay();
lcdcmd(0x01);
doorp=1;
doorn=0;
lcddis("OPENING DOOR");
lcdcmd(0xc0);
lcddis("PLEASE GO INSIDE");
mdelay();
doorp=0;
doorn=0;
lcdcmd(0x01);
doorp=0;
doorn=1;
lcddis("CLOSING DOOR");
mdelay();
doorp=0;
doorn=0;
}
//RFID TAG OF BILL CLINTON-D58END83MS9E
else if(rfid[0]=='D'&&rfid[1]=='5'&&rfid[2]=='8'&&rfid[3]=='E'&&rfid[4]=='N'&&rfid[5]=='D'&&rfid[6]=='8'&&rfid[7]=='3'&&rfid[8]=='M'&&rfid[9]=='S'&&rfid[10]=='9'&&rfid[11]=='E')
//if loop for comparing rfid tag positions from 0 to 7 with respective number as given above
{
lcdcmd(0x01);
lcddis("TEAM MEMBER");
lcdcmd(0xc0);
lcddis("CLINTON-SLOT 4");
mdelay();
lcdcmd(0x01);
doorp=1;
doorn=0;
lcddis("OPENING DOOR");
lcdcmd(0xc0);
lcddis("PLEASE GO INSIDE");
mdelay();
doorp=0;
doorn=0;
lcdcmd(0x01);
doorp=0;
doorn=1;
lcddis("CLOSING DOOR");
mdelay();
doorp=0;
doorn=0;
}
else
{
lcdcmd(0x01);
lcddis("DONALD TRUMP");
lcdcmd(0xc0);
lcddis("GET OUT !!!");
mdelay();
}
}
void serial_init()
{
SCON=0X50; //serial comm with recieve enable mode
TMOD=0X20; //timer mode 2
TH1=-3; //baud rate 9600
TR1=1; //start timer
}
void lcd_init()
{
lcdcmd(0x38); //initialize 5x7 matrix lcd
lcdcmd(0x01); //clear screen
lcdcmd(0x10); //shift cursor to right
lcdcmd(0x0c); //display on cursor off
lcdcmd(0x80); //start display from first line first position
}
void lcdcmd(unsigned char val)
{
P1=val;
rs=0;
rw=0;
en=1; //high
delay(); //to
en=0; //low
}
void lcddat(unsigned char val)
{
P1=val;
rs=1;
rw=0;
en=1; //without going en from high to low, it wont allow to display next chr
delay();
en=0;
}
void lcddis(unsigned char *s) //unsigned chr equated with s
{
unsigned char w; //w is tem var
for(w=0;s[w]!='\0';w++) //to pass strng of words, chr by chr. comapre s[w] with null chr \n,
//loop continues untill unless it wont get s[w] equal to null chr
{
lcddat(s[w]);
}
}
void delay()
{
unsigned int v5;
for(v5=0;v5<6000;v5++);
}
void mdelay()
{
unsigned int v6,v7;
for(v6=0;v6<2;v6++)
{
for(v7=0;v7<60000;v7++);
}
}
Free online courses with Free Certificate
Free online courses with Free Certificate
Free online courses with Free Certificate
Proteus:
Download link: Click here !
step: right click on "Proteus 8 professional"(whichever version available) and "run as administrator"
step: now go to project >> new project >> "New Project.pdsprj"
step: click on "P" and open window for "pick devices" as shown below
step: now type "at89c51" and select microcontroller then press ok
step: now add other components as shown below:
1. Motor driver as L293D :
2. 20X2 LCD Display as LM032L:
step: now final circuit as shown below
step: now double click on microcontroller symbol then "edit component" window will open. then click on "folder symbol" to select ".hex" file and change frequency to 11.0592MHz as shown below
Note- make sure you know path of ".hex" file generated through Keil c51 as shown below
e.g. - ..\..\..\Keil_v5\C51\Examples\my project\Objects\7segment 8051.hex
step: click on "play button" and check output as shown below
Check actual simulation in GIF format as shown below
If you found any difficulty or any suggestions please comment below or contact me on "pangfreelearner@gmail.com".
And also visit my YouTube channel for "Free online courses with Free certificate" on below link.
Free online courses with Free Certificate
Join Facebook group for Free online courses with Free certificate
Thank you.
PANG.