一个比较简单实用的LCD显示程序
单片机源程序如下:
- #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)
|