合肥学院第八届电子设计竞赛
;
} P3=0xfb; if(P3!=0xfb) { 元
DelayMs(40); if(P3!=0xfb) {
switch(P3&0xf0) {
}
}
if(P3!=0xfd); DelayMs(30); while(P3!=0xfd);
case 0x70:LCD_Write_String(0,3,\杏子
LCD_Write_Com(0x8a);B=(unsigned
0.1555\
int )(A*0.1555);LCD_Write_Data(B/10000+0x30);LCD_Write_Data(B000/1000+0x30);LCD_Write_Data('.');LCD_Write_Data(B00/100+0x30);LCD_Write_Data(B0/10+0x30);LCD_Write_Data(B+0x30);break;
元
case 0xb0:LCD_Write_String(0,3,\香蕉
LCD_Write_Com(0x8a);B=(unsigned
0.2555\
int )(A*0.2555);LCD_Write_Data(B/100000+0x30);LCD_Write_Data(B0000/10000+0x30);LCD_Write_Data(B000/1000+0x30);LCD_Write_Data('.');LCD_Write_Data(B00/100+0x30);LCD_Write_Data(B0/10+0x30);LCD_Write_Data(B+0x30);break;
case 0xd0:LCD_Write_String(0,3,\猪腰
31
合肥学院第八届电子设计竞赛
0.5555元\LCD_Write_Com(0x8a);B=(unsigned
int )(A*0.5555);LCD_Write_Data(B/100000+0x30);LCD_Write_Data(B0000/10000+0x30);LCD_Write_Data(B000/1000+0x30);LCD_Write_Data('.');LCD_Write_Data(B00/100+0x30);LCD_Write_Data(B0/10+0x30);LCD_Write_Data(B+0x30);break;
元
case 0xe0:LCD_Write_String(0,3,\猴脑
LCD_Write_Com(0x8a);B=(unsigned
0.6666\
int )(A*0.666);LCD_Write_Data(B/100000+0x30);LCD_Write_Data(B0000/10000+0x30);LCD_Write_Data(B000/1000+0x30);LCD_Write_Data('.');LCD_Write_Data(B00/100+0x30);LCD_Write_Data(B0/10+0x30);LCD_Write_Data(B+0x30);break; } }
}
}
}
if(P3!=0xfb); DelayMs(30); while(P3!=0xfb);
8.5.12864.程序
#include \#include \
sbit RS = P2^4; //定义端口 sbit RW = P2^5; sbit EN = P2^6; sbit RES = P2^3; sbit PSB = P2^1; sbit PAUSE = P3^0; #define RS_CLR RS=0
32
合肥学院第八届电子设计竞赛
#define RS_SET RS=1 #define RW_CLR RW=0 #define RW_SET RW=1 #define EN_CLR EN=0 #define EN_SET EN=1 #define DataPort P0
/*------------------------------------------------ 判忙函数
------------------------------------------------*/ bit LCD_Check_Busy(void) {
DataPort= 0xFF; RS_CLR; RW_SET; EN_CLR; _nop_(); EN_SET;
return (bit)(DataPort & 0x80); }
/*------------------------------------------------ 写入命令函数
------------------------------------------------*/ void LCD_Write_Com(unsigned char com) {
while(LCD_Check_Busy()); //忙则等待 RS_CLR; RW_CLR; EN_SET;
33
合肥学院第八届电子设计竞赛
DataPort=com; _nop_(); EN_CLR; }
/*------------------------------------------------ 写入数据函数
------------------------------------------------*/ void LCD_Write_Data(unsigned char Data) {
while(LCD_Check_Busy()); //忙则等待 RS_SET; RW_CLR; EN_SET;
DataPort= Data; _nop_(); EN_CLR; }
/*------------------------------------------------ 清屏函数
------------------------------------------------*/ void LCD_Clear(void) {
LCD_Write_Com(0x01); DelayMs(5); }
/*------------------------------------------------ 写入字符串函数
------------------------------------------------*/
void LCD_Write_String(unsigned char x,unsigned char y,unsigned char
34
合肥学院第八届电子设计竞赛
*s) {
if (y == 0)
{
LCD_Write_Com(0x80 + x); //表示第一行
}
if (y == 1)
{
LCD_Write_Com(0x90 + x); //表示第一行
}
if (y == 2)
{
LCD_Write_Com(0x88 + x); //表示第一行
}
if (y == 3)
{
LCD_Write_Com(0x98 + x); //表示第一行
}
while (*s) {
LCD_Write_Data( *s); s ++; } }
void LCD_Write_Char(unsigned char x,unsigned char y,unsigned char Data) {
if (y == 0) {
35
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库电子设计竞赛设计报告 - 图文(7)在线全文阅读。
相关推荐: