#include<reg52.h> #include<intrins.h>#define uchar unsigned char#define uint unsigned intuchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0};uchar num,x,y,a;uint temp;void init();void display(uint num);uint keyscan();void delay(uint z){ for(x=z;x>0;x--) for(y=110;y>0;y--);}
void main(){ while(1) { display(keyscan()); } } void display(uint num){ P1=0x00; P0=table[num];}
uint keyscan(){ temp=P2; temp=temp&0xf0; while(temp!=0xf0) { temp=P2; switch(temp) { case 0x77:num=1;break; case 0x7b:num=2;break; case 0x7d:num=3;break; case 0x7e:num=4;break; case 0xb7:num=5;break; case 0xbb:num=6;break; case 0xbd:num=7;break; case 0xbe:num=8;break; case 0xd7:num=9;break; case 0xdb:num=10;break; case 0xdd:num=11;break; case 0xde:num=12;break; case 0xe7:num=13;break; case 0xeb:num=14;break; case 0xed:num=15;break; case 0xee:num=16;break; } } return num;}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>