完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
unsigned char Keyscan(void)
{ unsigned char x,y,Key_back=0; SCAN_IO=0x0f; if(SCAN_IO!=0x0f)//读取按键是否按下 { Delay10ms(10);//延时10ms进行消抖 if(SCAN_IO!=0x0f)//再次检测键盘是否按下 { x = SCAN_IO; SCAN_IO=0xf0; y = SCAN_IO; x = x|y; switch(x) { case(0Xe7): {Key_back=1;}break; case(0Xeb): {Key_back=2;}break; case(0Xed): {Key_back=3;}break; case(0Xee): {Key_back=4;}break; case(0Xd7): {Key_back=5;}break; case(0Xdb): {Key_back=6;}break; case(0xdd): {Key_back=7;}break; case(0Xde): {Key_back=8;}break; case(0Xb7): {Key_back=9;}break; case(0Xbb): {Key_back=10;}break; case(0Xbd): {Key_back=11;}break; case(0Xbe): {Key_back=12;}break; case(0X77): {Key_back=13;}break; case(0X7b): {Key_back=14;}break; case(0X7d): {Key_back=15;}break; case(0X7e): {Key_back=16;}break; default:Key_back=0;break; } } } return(Key_back); }
|
|
相关推荐
1个回答
|
|
#include
#define uint unsigned int #define uchar unsigned char ***it dula=P2^6; ***it wela=P2^7; ***it key1=P3^4; uchar code table[]={ 0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71,0}; uchar num,temp,num1; void delay(uint z) { uint x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); } uchar keyscan(); void display(uchar aa); void main() { num=17; dula=1; P0=0; dula=0; wela=1; P0=0xc0; wela=0; while(1) { display(keyscan()); } } void display(uchar aa) { dula=1; P0=table[aa-1]; dula=0; } uchar keyscan() { P3=0xfe; temp=P3; temp=temp&0xf0; while(temp!=0xf0) { delay(5); temp=P3; temp=temp&0xf0; while(temp!=0xf0) { temp=P3; switch(temp) { case 0xee:num=1; break; case 0xde:num=2; break; case 0xbe:num=3; break; case 0x7e:num=4; break; } while(temp!=0xf0) { temp=P3; temp=temp&0xf0; } } } P3=0xfd; temp=P3; temp=temp&0xf0; while(temp!=0xf0) { delay(5); temp=P3; temp=temp&0xf0; while(temp!=0xf0) { temp=P3; switch(temp) { case 0xed:num=5; break; case 0xdd:num=6; break; case 0xbd:num=7; break; case 0x7d:num=8; break; } while(temp!=0xf0) { temp=P3; temp=temp&0xf0; } } } P3=0xfb; temp=P3; temp=temp&0xf0; while(temp!=0xf0) { delay(5); temp=P3; temp=temp&0xf0; while(temp!=0xf0) { temp=P3; switch(temp) { case 0xeb:num=9; break; case 0xdb:num=10; break; case 0xbb:num=11; break; case 0x7b:num=12; break; } while(temp!=0xf0) { temp=P3; temp=temp&0xf0; } } } P3=0xf7; temp=P3; temp=temp&0xf0; while(temp!=0xf0) { delay(5); temp=P3; temp=temp&0xf0; while(temp!=0xf0) { temp=P3; switch(temp) { case 0xe7:num=13; break; case 0xd7:num=14; break; case 0xb7:num=15; break; case 0x77:num=16; break; } while(temp!=0xf0) { temp=P3; temp=temp&0xf0; } } } return num; }
最佳答案
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
嵌入式学习-飞凌嵌入式ElfBoard ELF 1板卡-使用AHT20进行环境监测之AHT20传感器介绍
727 浏览 0 评论
815 浏览 0 评论
850 浏览 1 评论
基于瑞萨FPB-RA4E2智能床头灯项目——1编译环境搭建与点亮驱动ws2812全彩LED
823 浏览 0 评论
嵌入式学习-飞凌嵌入式ElfBoard ELF 1板卡-LCD显示图片编程示例之介绍mmap
1274 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
11816 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-28 23:18 , Processed in 0.552879 second(s), Total 74, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号