欢迎来到天天文库
浏览记录
ID:37850204
大小:35.00 KB
页数:5页
时间:2019-06-01
《4乘4键盘控制LCD1602》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#include//P0口为数据命令接口可更改#defineuintunsignedint#defineucharunsignedcharsbitjian0=P2^0;//键盘扫描接口sbitjian1=P2^1;//键盘扫描接口sbitjian2=P2^2;//键盘扫描接口sbitjian3=P2^3;//键盘扫描接口sbitjian4=P2^4;//键值分辨接口sbitjian5=P2^5;//键值分辨接口sbitjian6=P2^6;//键值分辨接口sbitjian7=P2^7;//键值分辨接口//write_com(0x18);//整屏左移可用sbitLCD_E=P1
2、^2;//接口sbitLCD_RW=P1^1;//接口sbitLCD_RS=P1^0;//接口ucharcodetable[]="DuANan";//显示字样ucharcodetable1[]="ChengHong";//显示字样ucharnum;voiddelay(uintz){uintx,y;for(x=z;x>0;x--)for(y=110;y>0;y--);}voidwrite_com(ucharcom)//写指令小程序读指令时需要更改{LCD_RS=0;LCD_RW=0;P0=com;delay(5);LCD_E=1;delay(5);LCD_E=0;LCD_RS=1;}voidwr
3、ite_data(uchardate)//写数据小程序读数据时需要更改{LCD_RS=1;LCD_RW=0;P0=date;delay(5);LCD_E=1;delay(5);LCD_E=0;LCD_RS=0;}voidLCD_jian1(){write_data('1');delay(10);}voidLCD_jian2(){write_data('2');delay(10);}voidLCD_jian3(){write_data('3');delay(10);}voidLCD_jian4(){write_data('+');delay(10);}voidLCD_jian5(){write_
4、data('4');delay(10);}voidLCD_jian6(){write_data('5');delay(10);}voidLCD_jian7(){write_data('6');delay(10);}voidLCD_jian8(){write_data('-');delay(10);}voidLCD_jian9(){write_data('7');delay(10);}voidLCD_jian10(){write_data('8');delay(10);}voidLCD_jian11(){write_data('9');delay(10);}voidLCD_jian12(){wr
5、ite_data('*');delay(10);}voidLCD_jian13(){write_com(0x80+0x28);delay(10);}voidLCD_jian14(){write_com(0x01);delay(10);}voidLCD_jian15(){write_data('=');delay(10);}voidLCD_jian16(){write_data('/');delay(10);}voidkey44()//键值分辨{if(jian4==0){if(jian0==0){LCD_jian1();}elseif(jian1==0){LCD_jian2();}elseif(
6、jian2==0){LCD_jian3();}elseif(jian3==0){LCD_jian4();}delay(300);//消抖}if(jian5==0){if(jian0==0){LCD_jian5();}elseif(jian1==0){LCD_jian6();}elseif(jian2==0){LCD_jian7();}elseif(jian3==0){LCD_jian8();}delay(300);//消抖}if(jian6==0){if(jian0==0){LCD_jian9();}elseif(jian1==0){LCD_jian10();}elseif(jian2==0)
7、{LCD_jian11();}elseif(jian3==0){LCD_jian12();}delay(300);//消抖}if(jian7==0){if(jian0==0){LCD_jian13();}elseif(jian1==0){LCD_jian14();}elseif(jian2==0){LCD_jian15();}elseif(jian3==0){LCD_jian16();}delay
此文档下载收益归作者所有