44矩阵键盘控制液晶1602程序
44矩阵键盘控制液晶1602程序 #include
#include
#define uchar unsigned char #define uint unsigned int #define shuju P0 //数据 #define bus P3 //键盘 sbit rs=P1^0; sbit rw=P1^1; sbit e=P1^2; sbit sda=P0; //IO口定义 sbit scl=P2^1; // uchar r; void delayms(int i) { int j; for(j=0;j 0; shuju=0x01; enable(); shuju=0x38; enable(); shuju=0x0f; enable(); shuju=0x06; enable(); shuju=0x80; enable(); } void display(uchar i) { //uchar a; shuju=i; write(); } void jianpan() { uchar a; uchar k; bus=0xff; bus=0xef; //扫描第一行 delayms(600); a=bus; a=a&0x0f; if(a!=0x0f) { delayms(200); if(a!=0x0f) { switch(a) { case 0x0e: k=0x30; break; case 0x0d: k=0x34; break; case 0x0b: k=0x38; break; case 0x07: k=0x43; break; } display(k); r=r-1; while(a!=0x0f) { bus=0x0f; delayms(200); a=bus; //a=a&0x0f; } } } bus=0xdf; //扫描第二行 // lcdbus=0xff; delayms(600); a=bus; a=a&0x0f; if(a!=0x0f) { delayms(200); if(a!=0x0f) { switch(a) { case 0x0e: k=0x31; // shuju=0x05; break; case 0x0d: k=0x35; // shuju=0x06; break; case 0x0b: k=0x39; shuju=0x07; break; case 0x07: k=0x44; // shuju=0x08; break; } display(k); r=r-1; while(a!=0x0f) { bus=0x0f; delayms(200); a=bus; } } } bus=0xbf; //扫描第3行 delayms(600); a=bus; a=a&0x0f; if(a!=0x0f) { delayms(200); if(a!=0x0f) { switch(a) { case 0x0e: k=0x32; break; case 0x0d: k=0x36; break; case 0x0b: k=0x41; //k=58; // jia(); break; case 0x07: k=0x45; // jian(); break; } display(k); r=r-1; while(a!=0x0f) { bus=0x0f; delayms(200); a=bus; } } } bus=0x7f; //扫描第4行 delayms(600); a=bus; a=a&0x0f; if(a!=0x0f) { delayms(200); if(a!=0x0f) { switch(a) { case 0x0e: k=0x33; // jia(); // shuju=0x13; break; case 0x0d: k=0x37; //jian(); // shuju=0x14; break; case 0x0b: k=0x42; //cheng(); // shuju=0x50; break; case 0x07: k=0x46; //chu(); //shuju=0x16; break; } display(k); r=r-1; //a=lcdbus; // a=a&0x0f; while(a!=0x0f) { bus=0x0f; delayms(200); a=bus; } } } } void main() { while(1) { chushi(); r=0x10; while(r>0) { jianpan(); } shuju=0xc0; enable(); r=0x10; while(r>0) { jianpan(); } } } ...展开详情收缩
文件列表
44矩阵键盘控制液晶1602程序.rar
(预估有个11文件)
44矩阵键盘控制液晶1602程序
1602
7KB
1602.Opt
1016B
1602.hex
1KB
1602.plg
3KB
1602.OBJ
8KB
1602.c
4KB
1602.M51
12KB
1602.Uv2
2KB
1602.LST
12KB
暂无评论