完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
代码没有问题,但是矩阵按键按下后lcd1602没有反应,为什么呢,大佬求助!!!!!
#include #include #define uchar unsigned char #define uint unsigned int #define KEY P1 unsigned char Keyscan(); void lcd_write_com(unsigned char com); void lcd_write_dat(unsigned char dat); //void lcd_xy(unsigned char x,unsigned char y); void lcd_Init(); //uchar code table[16]; uchar code table[]= { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 }; extern key; void main(){ //char i; while(1){ Keyscan(); lcd_write_dat(table[key]); } } void lcd_write_com(unsigned char com); void lcd_write_dat(unsigned char dat); //void lcd_xy(unsigned char x,unsigned char y); //void delay1ms(uint z); void display(); /*uchar code table[]= { 0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71, };*/ uchar temp,key; void delay(uint xms)//°´¼üÑÓʱÏû¶¶º¯Êý { uint i,j; for(i=xms;i>0;i--) for(j=120;j>0;j--); } //ɨÃ躯Êý unsigned char Keyscan() { P1=0xf0; temp=P1; if(temp != 0xf0) { delay(10); temp=P1; if(temp != 0xf0) { temp=0xf0; switch(temp) { case 0xee: key=1;break; case 0xde: key=2;break; case 0xbe: key=3;break; case 0x7e: key=4;break; case 0xed: key=5;break; case 0xdd: key=6;break; case 0xbd: key=7;break; case 0x7d: key=8;break; case 0xeb: key=9;break; case 0xdb: key=10;break; case 0xbb: key=11;break; case 0x7b: key=12;break; case 0xe7: key=13;break; case 0xd7: key=14;break; case 0xb7: key=15;break; case 0x77: key=16;break; default:break; } while(temp != 0xf0) { temp=P1; temp=temp&0xf0; } return temp; } } return 0; } sbit RS = P3^5; sbit RW = P3^6; sbit E = P3^7; void lcd_write_com(unsigned char com); void lcd_write_dat(unsigned char dat); void lcd_xy(unsigned char x,unsigned char y); //void lcd_read_busy(); //void fbusy(); /*void delay1ms(uint z) { uint x,y; for(x=z;x>0;x--) for(y=120;y>0;y--); } */ /**********³õʼ»¯*******/ void lcd_Init(){ lcd_write_com(0x38); //ÉèÖÃÏÔʾģʽ lcd_write_com(0x0c); //¿ªÏÔʾ²»ÏÔʾ¹á±ê lcd_write_com(0x06); //Ö¸Õë×Ô¶¯¼ÓÒ» lcd_write_com(0x01); //ÇåÆÁ lcd_write_com(0x80); //ÉèÖÃÊý¾ÝÖ¸ÕëÆðµã } /**********дָÁî************/ void lcd_write_com(unsigned char com){ //fbusy(); RS = 0; RW = 0; E = 1; P0 = com; E = 0; } /*********дÊý¾Ý************/ void lcd_write_dat(unsigned char dat){ //fbusy(); RS = 1; RW = 0; E = 1; P0 = dat; E = 0; }
|
|
相关推荐
1个回答
|
|
lcd1602初始化函数没有用上吧
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
787 浏览 0 评论
使用Keil建立完整的工程,并使用外部中断0触发数码管显示903
1476 浏览 0 评论
嵌入式学习-飞凌嵌入式ElfBoard ELF 1板卡-使用AHT20进行环境监测之AHT20传感器介绍
1216 浏览 0 评论
900 浏览 0 评论
963 浏览 1 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
11866 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-4 03:01 , Processed in 0.786522 second(s), Total 70, Slave 52 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号