找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

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

字符液晶1602

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:299493 發(fā)表于 2018-8-22 10:04 | 只看該作者 回帖獎勵 |倒序?yàn)g覽 |閱讀模式
#include <REGX52.H>
#include "LCD1602.h"

unsigned char TempBuffer[10];
void IntToStr(unsigned int t, unsigned char *str, unsigned char n)
{
        unsigned char a[5]; char i, j;                                        
        a[0]=(t/10000)%10;         //取得整數(shù)值到數(shù)組                
        a[1]=(t/1000)%10;                                            
        a[2]=(t/100)%10;                                             
        a[3]=(t/10)%10;                                              
        a[4]=(t/1)%10;                                               

        for(i=0; i<5; i++)         //轉(zhuǎn)成ASCII碼                     
                a[i]=a[i]+'0';                                           
        for(i=0; a[i]=='0' && i<=3; i++);                            
        for(j=5-n; j<i; j++)       //填充空格                        
                { *str=' ';  str++; }                                    
        for(; i<5; i++)                                              
                { *str=a[i]; str++; }  //加入有效的數(shù)字                  
        *str='\0';
}

void Delay1ms(unsigned int count)
{
        unsigned int i,j;
        for(i=0;i<count;i++)
        for(j=0;j<120;j++);
}

main()
{
        unsigned int Count = 0;
        LCD_Initial();
        GotoXY(0,0);
        Print("The 1602LCD Test");
        GotoXY(0,1);
        Print("GO:       by JJJ");

        while(1)
        {
                IntToStr(Count++,&TempBuffer[0],5);
                GotoXY(3,1);
                Print(&TempBuffer[0]);
                Delay1ms(100);
        }
}


字符液晶1602.zip

19.04 KB, 下載次數(shù): 4, 下載積分: 黑幣 -5

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

使用道具 舉報(bào)

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

本版積分規(guī)則

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

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

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