找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 1748|回復(fù): 0
收起左側(cè)

STC15單片機1602液晶屏比較方便輸出字符程序

[復(fù)制鏈接]
ID:397211 發(fā)表于 2021-11-10 10:57 | 顯示全部樓層 |閱讀模式
比較牛批的1602液晶程序,通過引號可以直接顯示在屏幕上

單片機源程序如下:
  1. #include "reg52.h"
  2. sbit rs=P2^0;  
  3. sbit rw=P2^1;
  4. sbit sn=P2^2;
  5. #define sjk P0
  6. void delay_ms(unsigned int q)
  7. {
  8.                         while(q--);
  9. }
  10. void Write_instruction_data1602(unsigned char q,w)
  11. {
  12.                         rs=q;
  13.                         delay_ms(1);
  14.                         sjk=w;
  15.                         sn=1;
  16.                         delay_ms(1);
  17.                         sn=0;
  18. }
  19. void liquid1602crystal()
  20. {
  21.                         Write_instruction_data1602(0,0x0c);
  22.                         Write_instruction_data1602(0,0x38);
  23.                         Write_instruction_data1602(0,0x06);
  24.                         Write_instruction_data1602(0,0x80+0x40) ;
  25. }
  26. void display_characters1602(bit q,unsigned char w,unsigned char *e)
  27. {
  28.                         if(q==0)
  29.         {
  30.                         Write_instruction_data1602(0,0x80+w);
  31.                         while(*e!='\0')
  32.                 {
  33.                         Write_instruction_data1602(1,*e);
  34.                         delay_ms(1);
  35.                         e++;
  36.                 }
  37.         }
  38.                         else
  39.         {
  40.                         Write_instruction_data1602(0,0x80+0x40+w);
  41.                         while(*e!='\0')
  42.                 {
  43.                         Write_instruction_data1602(1,*e);
  44.                         delay_ms(1);
  45.                         e++;
  46.                 }
  47.         }
  48. }
  49. void main()
  50. {
  51.                         rw=0;
  52.                         liquid1602crystal();
  53.                         display_characters1602(0,0,"2021/7/3 week6");
  54.                         display_characters1602(1,0,"20:30:56  27.0C");
  55.                         while(1);
  56. }
復(fù)制代碼

Keil代碼工程: Keil.7z (11.52 KB, 下載次數(shù): 6)

評分

參與人數(shù) 1黑幣 +10 收起 理由
admin + 10 共享資料的黑幣獎勵!

查看全部評分

回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

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

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

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