找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索

自己照著書(shū)寫(xiě)的單片機(jī)程序,但是運(yùn)行了LCD1602上面什么都不顯示,問(wèn)下哪有問(wèn)題?

查看數(shù): 2814 | 評(píng)論數(shù): 9 | 收藏 0
關(guān)燈 | 提示:支持鍵盤(pán)翻頁(yè)<-左 右->
    組圖打開(kāi)中,請(qǐng)稍候......
發(fā)布時(shí)間: 2022-12-21 19:02

正文摘要:

#include <reg51.h> #include <intrins.h> sbit DB=P0; sbit RS=P2^0; sbit RW=P2^1; sbit E=P2^2; void delay(unsigned int z) {         unsigned int x,y;   ...

回復(fù)

ID:755966 發(fā)表于 2022-12-26 13:24
人人學(xué)會(huì)單片機(jī) 發(fā)表于 2022-12-21 21:29
LCD1602液晶最新資料 說(shuō)明了具體的時(shí)間要求 http://www.torrancerestoration.com/bbs/dpj-205768-1.html

好的謝謝   
ID:755966 發(fā)表于 2022-12-26 13:24
lkc8210 發(fā)表于 2022-12-21 21:46
把第3行的sbit DB=P0;
改為#define  DB P0

好的 謝謝
ID:755966 發(fā)表于 2022-12-26 13:24
wulin 發(fā)表于 2022-12-21 21:13
抄的不仔細(xì),也沒(méi)有認(rèn)真檢查。

好的 謝謝
ID:755966 發(fā)表于 2022-12-26 13:24
陳潤(rùn)源home 發(fā)表于 2022-12-21 22:14
sbit DB=P0;   P0是8位   sbit是位定義

好的,謝謝
ID:57657 發(fā)表于 2022-12-21 22:22
RV1可能是假的,換成兩個(gè)電阻試試。
ID:293363 發(fā)表于 2022-12-21 22:14
sbit DB=P0;   P0是8位   sbit是位定義   
ID:161164 發(fā)表于 2022-12-21 21:46
把第3行的sbit DB=P0;
改為#define  DB P0

把write_com(0x3C);
改為write_com(0x38);
ID:390416 發(fā)表于 2022-12-21 21:29
LCD1602液晶最新資料 說(shuō)明了具體的時(shí)間要求 http://www.torrancerestoration.com/bbs/dpj-205768-1.html
ID:213173 發(fā)表于 2022-12-21 21:13
抄的不仔細(xì),也沒(méi)有認(rèn)真檢查。


  1. #include <reg51.h>
  2. #include <intrins.h>
  3. #define DB P0
  4. sbit RS=P2^0;
  5. sbit RW=P2^1;
  6. sbit E=P2^2;
  7. void delay(unsigned int z)
  8. {
  9.         unsigned int x,y;
  10.         for(x=z;x>0;x--)
  11.                 for(y=110;y>0;y--);
  12. }

  13. void write_dat(unsigned char dat)
  14. {        
  15.         RW=0;
  16.         RS=1;
  17.         DB=dat;
  18.         delay(5);
  19.         E=1;
  20.         delay(5);
  21.         E=0;
  22. }
  23. void write_com(unsigned char com)
  24. {        
  25.         RW=0;
  26.         RS=0;
  27.         DB=com;
  28.         delay(5);
  29.         E=1;
  30.         delay(5);
  31.         E=0;
  32. }
  33. void lcd_1602init()
  34. {
  35.         RW=0;
  36.         E=0;
  37.         write_com(0x38);
  38.         write_com(0x0c);
  39.         write_com(0x06);
  40.         write_com(0x01);
  41. //        write_com(0x80);
  42. }
  43. void write_sfm(unsigned char add,unsigned char date)
  44. {
  45.         unsigned char shi,ge;
  46.         shi=date/10;
  47.         ge=date%10;
  48.         write_com(0x80+add);
  49.         write_dat(0x30+shi);
  50.         write_dat(0x30+ge);
  51. }
  52. void main()
  53. {
  54.         lcd_1602init();
  55.         write_sfm(0,20);//寫(xiě)第一行
  56.         while(1)
  57.         {
  58.                 write_com(0xc0);//寫(xiě)第二行
  59.                 write_dat('2');
  60.                 write_dat('0');
  61.         }
  62. }
復(fù)制代碼



小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表