一個比較簡單實用的LCD顯示程序
0.png (11.8 KB, 下載次數: 29)
下載附件
2019-4-18 22:37 上傳
單片機源程序如下:
- #include <reg51.h>
- #include "mytype.h"
- #include "lcd1602.h"
- sbit KEY1 = P1^0;
- sbit KEY2 = P1^1;
- UINT8 temperature;
- UINT8 code Str3[]=" Welcome ! ";
- UINT8 code Str4[]=" Please wait ";
- UINT8 Strtemperature[17] = {"temperature: "};
- UINT8 Strhumidness[16] = " humidness:25\% ";
- void HexToSTring(UINT8 hex, UINT8 *str)
- {
- str[12] = (hex/10)%10 + '0';
- str[13] = hex%10 + '0';
- str[14] = 0xdf;
- str[15] = 'C';
- }
- void main()
- {
- Init_LCD();
- Display_LCD_String(0x00, Str3);
- Display_LCD_String(0x40, Str4);
-
- delay(2000); //延時2s
- temperature = 95;
-
- Display_LCD_String(0x00, Strhumidness);
-
- while(1)
- {
- if (KEY1 == 0)
- {
- delay(100);
- if (KEY1 == 0)
- {
- while(!KEY1);
- temperature++;
- if (temperature == 100)
- {
- temperature = 0;
- }
- }
- }
-
- if (KEY2 == 0)
- {
- delay(100);
- if (KEY2 == 0)
- {
- while(!KEY2);
-
- if (temperature > 0)
- ……………………
- …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
所有資料51hei提供下載:
液晶1602.rar
(67.65 KB, 下載次數: 91)
2019-4-18 17:10 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|