標(biāo)題: keilc實驗作業(yè)——基于c51的液晶顯示 [打印本頁]

作者: 拾玉    時間: 2017-1-3 18:31
標(biāo)題: keilc實驗作業(yè)——基于c51的液晶顯示
keilc實驗作業(yè)——基于c51的液晶顯示
標(biāo)準(zhǔn)答案分享
供同學(xué)參考下載



  1. #include <reg52.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("Welcom To SYIG");
  34.         GotoXY(0,1);
  35.         Print("GO:       by 100");

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


實驗四-LCD1602液晶顯示.zip

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


作者: jbw58377486    時間: 2017-1-8 17:51
剛好是作業(yè)




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1