shubham156
Newbie level 4
Sir, i want to control room devices by transmitting serially from virtual terminal to microcontroller.
That means if i write BULB ON in virtual terminal, the bulb connected to p0.0 glows
I have written a code but that is not working fine.
Please can you tell me the errors in this.
I am attaching the code and circuit diagram.
Circuit diagram:
That means if i write BULB ON in virtual terminal, the bulb connected to p0.0 glows
I have written a code but that is not working fine.
Please can you tell me the errors in this.
I am attaching the code and circuit diagram.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 #include<reg51.h> sfr ldata=0x90; sbit rs=P2^0; sbit rw=P2^1; sbit en=P2^2; void delay(); void lcdcmd(char value); void lcddata(char value); void main() { unsigned char p[40]="BULBON"; unsigned char q[40]; unsigned int i=0; unsigned int flag=0; unsigned char mybyte; P1=0; lcdcmd(0x81); delay(); lcdcmd(0x0E); delay(); lcdcmd(0x01); delay(); lcdcmd(0x06); delay(); TMOD=0x20; TH1=0xFd; SCON=0x51; TR1=1; while(1) { while(RI==0); mybyte=SBUF; while(mybyte!=0x20) { q[i]=mybyte; if(p[i]==q[i]) { flag=1; } i++; if((mybyte==0x08)||(mybyte==0x7f)) lcdcmd(0x01); lcddata(mybyte); } if(flag==1) P0=1; RI=0; delay(); } } void lcdcmd(char value) { ldata=value; rs=0; rw=0; en=1; delay(); en=0; } void lcddata(char value) { ldata=value; rs=1; rw=0; en=1; delay(); en=0; } void delay() { int i,j; for(i=0;i<256;i++); for(j=0;j<256;j++); }
Circuit diagram:
Last edited by a moderator: