We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
#include<reg51.h>sbit ir1=P1^0; //entrysbit ir2=P1^1; //exitsbit rs=P2^0;sbit rw=P2^1;sbit en=P2^2;void lcdcmd(unsigned char);void lcddat(unsigned char);void lcddis(unsigned char *s,unsigned char r );void lcdconv(unsigned char);void delay();void main(){ unsigned char x,y; lcdcmd(0x38); delay(); lcdcmd(0x01); delay(); lcdcmd(0x10); delay(); lcdcmd(0x0c); delay(); lcddis("WELCOME",7); lcdcmd(0xc0); delay(); lcddis("VISITOR COUNTER",15); delay(); lcdcmd(0x01); delay(); while(1) { if(ir1==0) { lcdcmd(0x80); delay(); lcddis("ENTRY:",6); lcdcmd(0x87); delay(); x=x+1; lcdconv(x); } if(ir2==0) { lcdcmd(0xc0); lcddis("EXIT:",5); lcdcmd(0xc6); delay(); y=y+1; lcdconv(y); delay(); } }void lcdcmd(unsigned char val){P3=val;rs=0;rw=0;en=1;delay();en=0; } void lcddat(unsigned char dat){P3=dat;rs=1;rw=0;en=1;delay();en=0; }void lcddis(unsigned char *s,unsigned char r){unsigned char w; for(w=0;w<r;w++) { lcddat(s[w]); delay(); }}void lcdconv(unsigned char num){unsigned char p,n; p=num/10; n=num%10; p=p+0x30; n=n+0x30; lcddat(p); lcddat(n);}void delay(){unsigned char k,l; for(k=0;k<1000;k++); for(l=0;l<100;l++);}
You're missing the closing brace to the while loop. The code you need is }, properly placed.
Some indentation would help you find these errors more easily. Also, the MDK editor highlights parentheses so that it's easier to see matches. I'd hope the 8051 tools did, too. If they don't, editors like Visual Studio Code will.
Adam Lins said:Some indentation would help you find these errors more easily
Hopefully, the original code does actually have this - and it's just been lost in posting?
Heth - As with any internet forum, you can't just dump code into a post - you have to use the forum's code posting facility to maintain the formatting/layout:
www.avrfreaks.net/.../2477336