完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
`新出课设题目。我就在网上找了个电路图。
然后就遇到程序问题。 #include #include ***it RS=P2^0; ***it RW=P2^1; ***it E=P2^2; ***it BF=P1^7; char world[]="Welcome!"; char world1[]="Good morning!"; void delay1ms() { unsigned char i,j; for(i=0;i<10;i++) for(j=0;j<33;j++); } void delay(unsigned char n) { unsigned char i; for(i=0;i } void nop(unsigned s) { unsigned char i; for(i=0;i } //Test the LCD is busing(1) of not(0) unsigned char busytest(void) { bit result; RS=0; RW=1; E=1; nop(4); result=BF; E=0; return result; } //Writing the control world void writecontrol(unsigned condata) { while(busytest()==1); RS=0; RW=0; E=0; nop(2); P1=condata; nop(4); E=1; nop(4); E=0; } //Writing the data void writedata(unsigned d) { while(busytest()==1); RS=1; RW=0; E=0; P1=d; nop(4); E=1; nop(4); E=0; } void lcdinit(void) { delay(15); writecontrol(0x38);//8 bit;16*2;5*7 delay(5); writecontrol(0x38); delay(5); writecontrol(0x38); delay(5); writecontrol(0x0f);// 显示开,有光标,光标闪烁 delay(5); writecontrol(0x06);// 光标右移,字符不移 delay(5); writecontrol(0x01);// 清屏 delay(5); } void main() { unsigned char i; lcdinit(); delay(10); while(1) { writecontrol(0x01); writecontrol(0x80);// 第一行地址 i=0; while(world!=' |