This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Can u please help me resolve errors

#include<reg52.h> //header file
#define lcd P2
sbit rs=P3^7;
sbit rw=P3^6;
sbit en=P3^5;
sbit start=P1^2;
sbit stop=P1^1;
sbit buzzer=P1^0;
sbit slide_sw=P1^4;
sbit relay=P1^3;
void lcddata(unsigned char);
void lcdcmd(unsigned char);
void lcd_init( );
void delay(unsigned int);
void lcdstring(unsigned char*);
void display(unsigned char);
void delay1(unsigned long);
unsigned int time,speed;
unsigned int time_count;
unsigned int time_sec,sec;
void main()
{ unsigned char high_byte, low_byte;
unsigned int timel ;
lcd_init(); //Initialise the LCD
lcdcmd(0X80); //select LCD 1st line starting position
lcdstring(" SPEED CHECKER "); //Display string on LCD
lcdcmd(0XC0); //select the LCD2nfdline starting position
lcdstring(" FOR HIGHWAYS "); //display string on LCD
start=stop=1; //initialise the start&stop
while(1)
{ if(start==1)
lcdcmd(0X01); //cleear the LCD
lcdcmd(0X80); //select the LCD 1st line starting positAn
lcdstring(" START "); //display string on LCD
time_count=0; //clear the time_count
sec=0; //clear the seconds
time_sec=0; //clear the timesec
TMOD=0X10; //select the timerl in model mode
TH1=0X00; // load the timerl high count
TL1=0X00; //load the timerl low count
TMOD=0X01; //select the timer0 in model mode
TH0=0X00; // load the timer0 high count
TL0=0X00; // load the timer0 high count
TR0=1; //start the timer0
TR1=1; //start the timerl
} if(stop==1)
{ TR0=0; //stop the timer0
TR1=0; //stop the timed.
lcdcmd(0X80); //select the lcd 1st line starting position
lcdstring(" STOP "); //display string on LCD
high_byte=TH0; // copy the timer0 high count
low_byte=TL0; //copy the timer0 low count
delay1()
time=( (time_count*71.1066) + (( ((256*high_byte)+low_byte)*(1.085) ) )) ;//calculate the time
lcdcmd(0X80); //select the lcd 1st line starting position
lcdstring("TIME: "); //display string on LCD
lcdcmd(0X85); //select the lcd 1st line 5th position
timel=(time/1000);
display(timel); //dispaly the time
lcdcmd(0X8A); //select the lcd 1st line 10th position
lcdstring("sec");
lcdcmd(0XC0); //select the lcd 2nd line starting position
lcdstring("SPEED: "); //display the string on LCD
lcdcmd(0XC6); //select the lcd 2nd line 6th position
speed=(360/(timel)); // calculate the speed
display(speed); //dispaly the speed
lcdcmd(0XCA); //select the
lcdstring("KMPH");
if(slide_sw==0)
{ if(speed>40) // if speed is greater than 40KM
{ buzzer=1;//switch ON the buzzer relay=1 // switch ON the relay delay(50000); relay=0; //switch OFF relay
} else

{ buzzer=0; // switch OFF buzzer relay=0; //switch off relay
} if(slide_sw==1)
{ if(speed>60) //if speed MOR than 60KM { buzzer=1 // switch ON buzzer relay=1//switch ON relay delay(50000); relay=0; //switch off relay } else { buzzer=0;//swiych OFF buzzer relay=0; //switch off relay }
} }
} }
void lcd_init()
{ lcdcmd(0X38); //select 5x7 matrix lcd 8,6x2 LCD lcdcmd(0X0E); // display On curser blinking lcdcmd(0X06); // shift the curser to right lcdcmd(0X80); //select the lcd lst line starting position
} void lcdcmd(unsigned char cmd)
{ lcd=cmd; //copy the command on the Data bus rs=0; //rs=0 for command rw=0; //rw =0 for writing en=1; //make enable pin high en=0; //make enable pin low
} void lcddata(unsigned char dat)
{ lcd=dat; //copy the Data on the Data bus rs=1; //rs=1 for Data rw=0; //rw=0 for writing en=1; //make enable pin high en=0; //make enable pin low
} void lcdstring(unsigned char*str)
{ while(*str!='\0') { lcddata(*str); str++; }
} void display(unsigned char num) // display the speed
{ unsigned char templ,buffer[4],t=0; temp1=num%10; buffer[0]=templ+0X30; temp1=num%10; buffer[1]=templ+0X30; num=num/10; temp1=num%10; buffer[2] =templ+0X30; num = num/10; temp1=num%10; buffer[3]=templ+0X30; if(buffer[0]=='0') { if(buffer[1]=='0') { if(buffer[2]=='0') { lcddata(buffer[3]); return; }
else
{ for(t=2;t<=3;t++) lcddata(buffer[t]); return;
} } else { for(t=1;t<=3;t++); lcddata(buffer[t]); return; }
} else {
for(t=0;t<=3;t++);
lcddata(buffer[t]); }
} void delay(unsigned int itime)
{ unsigned int i;
for(i=0;i<itime;i++);
} void delay1()
{ unsigned int m,n; for(m=0;m<100;m++) { for(n=0;n<4000;n++); }
} void TIMERl_ISR()interrupt1 //timerlinterrupt service routine
{ unsigned int sec,time_sec; time_sec++; //increment the timesec
if(time_sec==60)
{ time_sec=0; sec++, lcdcmd(0XC7); display(sec); //display the time
} }
this is the code
i'm getting the following errors

Build target 'Target 1'
compiling done.c...
done.c(78): error C141: syntax error near 'delay'
done.c(92): error C141: syntax error near 'relay'
done.c(93): error C141: syntax error near 'delay'
done.c(139): error C202: 'temp1': undefined identifier
done.c(141): error C202: 'temp1': undefined identifier
done.c(144): error C202: 'temp1': undefined identifier
done.c(147): error C202: 'temp1': undefined identifier
done.c(184): error C236: '_delay1': different length of parameter lists
done.c(192): error C132: 'interrupt1': not in formal parameter list
done.c(192): error C141: syntax error near '{'
done.c(193): error C132: 'sec': not in formal parameter list
done.c(193): error C132: 'time_sec': not in formal parameter list
done.c(194): error C132: 'time_sec': not in formal parameter list
done.c(194): error C141: syntax error near '++'
done.c(197): error C244: 'time_sec': can't initialize, bad type or class
done.c(197): error C132: 'time_sec': not in formal parameter list
done.c(198): error C132: 'sec': not in formal parameter list
done.c(198): error C141: syntax error near '++'
done.c(199): error C132: 'lcdcmd': not in formal parameter list
done.c(200): error C132: '_display': not in formal parameter list
done.c(201): error C141: syntax error near '}'

Parents Reply Children