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

QQ登錄

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

搜索
查看: 2623|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

字符液晶1602 proteus仿真測(cè)試 帶單片機(jī)程序

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主


仿真工程文件及所有完整程序等資料下載地址:
http://www.torrancerestoration.com/bbs/dpj-56304-1.html

  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. }
復(fù)制代碼



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

使用道具 舉報(bào)

本版積分規(guī)則

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

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

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