找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 5172|回復: 1
打印 上一主題 下一主題
收起左側

基于c51單片機的lcd屏LM016L顯示字符的設計

[復制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:339405 發(fā)表于 2018-12-5 18:08 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)


單片機源程序如下:
  1. #include <REGX52.H>
  2. #include "LCD1602.h"

  3. unsigned char TempBuffer[10];
  4. void IntToStr(unsigned int t, unsigned char *str, unsigned char n)
  5. {
  6.         unsigned char a[5]; char i, j;                                        
  7.         a[0]=(t/10000)%10;         //取得整數(shù)值到數(shù)組                
  8.         a[1]=(t/1000)%10;                                            
  9.         a[2]=(t/100)%10;                                             
  10.         a[3]=(t/10)%10;                                              
  11.         a[4]=(t/1)%10;                                               
  12.                                                       
  13.         for(i=0; i<5; i++)         //轉(zhuǎn)成ASCII碼                     
  14.                 a[i]=a[i]+'0';                                           
  15.         for(i=0; a[i]=='0' && i<=3; i++);                            
  16.         for(j=5-n; j<i; j++)       //填充空格                        
  17.                 { *str=' ';  str++; }                                    
  18.         for(; i<5; i++)                                              
  19.                 { *str=a[i]; str++; }  //加入有效的數(shù)字                  
  20.         *str='\0';
  21. }

  22. void Delay1ms(unsigned int count)
  23. {
  24.         unsigned int i,j;
  25.         for(i=0;i<count;i++)
  26.         for(j=0;j<120;j++);
  27. }

  28. main()
  29. {
  30.         unsigned int Count = 0;
  31.         LCD_Initial();
  32.         GotoXY(0,0);
  33.         Print("The 1602LCD Test");
  34.         GotoXY(0,1);
  35.         Print("GO:       by JJJ");

  36.         while(1)
  37.         {
  38.                 IntToStr(Count++,&TempBuffer[0],5);
  39.                 GotoXY(3,1);
  40.                 Print(&TempBuffer[0]);
  41.                 Delay1ms(100);
  42.         }
  43. }
復制代碼

所有資料51hei提供下載:
0015、字符液晶1602仿真測試.zip (74.23 KB, 下載次數(shù): 41)


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

沙發(fā)
ID:651220 發(fā)表于 2019-11-27 23:21 | 只看該作者
程序復制下來說有錯誤呀
回復

使用道具 舉報

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

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

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

快速回復 返回頂部 返回列表