新人求助啊!LCD1602的编程错误!!!

2019-07-15 18:56发布

完全找不到头绪啊!!
#include<reg51.h>
#define LCD1602_DATAPINS P0;
sbit LCD_RS=P2^6;
sbit LCD_RW=P2^5;
sbit 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条回答
greenho
1楼-- · 2019-07-15 20:28
20行是“ LCD1602_DATAPINS=com;”,51行是“  LCD1602_DATAPINS=dat;”
hm3lin
2楼-- · 2019-07-15 21:01
第二行,define后面无需分号
阿信509
3楼-- · 2019-07-15 23:10
 精彩回答 2  元偷偷看……
nsj21n
4楼-- · 2019-07-16 00:21
同意“#define LCD1602_DATAPINS P0;”后面去掉分号   #define LCD1602_DATAPINS P0
fg888fg888
5楼-- · 2019-07-16 06:03
目测了一下楼主的延时函数很有个性,不知道为什么这么写!!
提示错误主要是
20行是“ LCD1602_DATAPINS=com;”,51行是“  LCD1602_DATAPINS=dat;”都是因为有 LCD1602_DATAPINS,就是三楼所说的,除去宏定义上面的分号。
阿信509
6楼-- · 2019-07-16 11:52
他的那个延时肯定有问题,多了分号了

一周热门 更多>