新手求助,51单片机LCD问题。谢谢

[复制链接]
1085|3
 楼主| 马大壮 发表于 2016-12-2 19:15 | 显示全部楼层 |阅读模式
在proteus上模拟LCD,但一直不能显示C:\Users\马大壮\Desktop


  1. #include <reg52.h>
  2. #define uint  unsigned int
  3. #define uchar unsigned char
  4. #define LCD_DB P3
  5. sbit LCD_RW=P2^1;
  6. sbit LCD_RS=P2^0;
  7. sbit LCD_EN=P2^3;
  8. uchar code table[]="I LOVE YOU!";
  9. uchar num;
  10. void delay(uchar z)
  11. {
  12.      uint x,y;
  13.      for(y=z;y>0;y--)
  14.          for(x=110;x>0;x--);
  15. }

  16. /************ LCD COMMOND ********/
  17. void LCD_write_com(uchar com)
  18. {
  19.      LCD_RS=0;
  20.      LCD_DB=com;
  21.      delay(5);
  22.      LCD_EN=1;
  23.      delay(5);
  24.      LCD_EN=0;
  25. }
  26. /********** LCD DATA *************/
  27. void LCD_write_dat(uchar dat)
  28. {
  29.      LCD_RS=1;
  30.      LCD_DB=dat;
  31.      delay(5);
  32.      LCD_EN=1;
  33.      delay(5);
  34.      LCD_EN=0;
  35. }
  36. /************ LCD INIT ************/
  37. void LCD_Init()
  38. {
  39.      LCD_EN=0;
  40.      LCD_write_com(0x38);
  41.      LCD_write_com(0x0e);
  42.      LCD_write_com(0x06);
  43.      LCD_write_com(0x01);
  44.    //  LCD_write_com(0x80+0x10);
  45. }
  46. ////////////////////////////////////////
  47. void main()
  48. {
  49.      LCD_RW=0;
  50.      LCD_Init();
  51.      for(num=0;num<11;num++)
  52.      {
  53.           LCD_write_dat(table[num]);
  54.           delay(600);
  55.      }
  56.      while(1);
  57. }

chuangbao 发表于 2016-12-3 17:50 | 显示全部楼层
这是lcd1602吗?
dirtwillfly 发表于 2016-12-4 18:46 | 显示全部楼层
用实物呢?能显示吗?
NE5532 发表于 2016-12-4 21:58 | 显示全部楼层
别抱着充气娃娃(仿真)不放了,找个女朋友(实物)吧。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

1

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部