完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
完全找不到头绪啊!!
#include #define LCD1602_DATAPINS P0; ***it LCD_RS=P2^6; ***it LCD_RW=P2^5; ***it LCD_E=P2^7; unsigned char code DATA[]="I Want You" ; void Delay1ms(unsigned int c) { unsigned char a,b; for(;c>0;c--); for(a=38;a>0;a--); for(b=130;b>0;b--); } void lcdcom(unsigned char com) { LCD_E=0; LCD_RS=0; LCD_RW=0; LCD1602_DATAPINS=com; Delay1ms(10); LCD_E=1; Delay1ms(10); LCD_E=0; } void lcddat(unsigned char dat) { LCD_E=0; LCD_RS=1; LCD_RW=0; LCD1602_DATAPINS=dat; Delay1ms(10); LCD_E=1; Delay1ms(10); LCD_E=0; } void lctinit() { lcdcom(0x38); lcdcom(0x0c); lcdcom(0x06); lcdcom(0x01); } void main() { lcdinit(); while(1) { unsigned char i; lcdcom(0x80); for(i=0;i<9;i++) { lcddat(DATA[i]); } } } Build target 'Target 1' compiling lcd.c... LCD.C(20): warning C275: expression with possibly no effect LCD.C(20): error C141: syntax error near '=' LCD.C(51): error C141: syntax error near '=' Target not created |
|
相关推荐
14个回答
|
|
第二行,define后面无需分号
|
|
|
|
#define LCD1602_DATAPINS P0;这个后面不需要分号的
|
|
|
|
同意“#define LCD1602_DATAPINS P0;”后面去掉分号 #define LCD1602_DATAPINS P0
|
|
|
|
目测了一下楼主的延时函数很有个性,不知道为什么这么写!!
提示错误主要是 20行是“ LCD1602_DATAPINS=com;”,51行是“ LCD1602_DATAPINS=dat;”都是因为有 LCD1602_DATAPINS,就是三楼所说的,除去宏定义上面的分号。 |
|
|
|
他的那个延时肯定有问题,多了分号了
|
|
|
|
|
|
|
|
或者 #include #define uchar unsigned char #define uint unsigned int ***it rs=P2^6; ***it lcden=P2^7; ***it rw=P2^5; uchar i; uchar code table[]={"I Want You! "}; void delay(uint z) { uint x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); } void write_com(uchar com) { rs=0; lcden=0; P2=com; delay(5); lcden=1; delay(5); lcden=0; } void write_date(uchar date) { rs=1; lcden=0; P2=date; delay(5); lcden=1; delay(5); lcden=0; } void init() { write_com(0x38); write_com(0x0c); write_com(0x06); write_com(0x01); } void main() { init(); while(1) { write_com(0x80); while(table[i]!=' |