#include<reg51.h>#define uint unsigned int#define uchar unsigned charbit flag;unsigned char key_scannum[] = {0xef,0xdf,0xbf,0x7f};unsigned char table[]= {0xee,0xed,0xeb,0xe7,0xde,0xdd,0xdb,0xd7,0xbe,0xbd,0xbb,0xb7,0x7e,0x7d,0x7b,0x77};//¼üÅÌ°´¼üÂëunsigned char led[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff}; //P0¿Ú¶ÎÂë±àÂë
void delay(uint x) //ÑÓʱ³ÌÐò{uint y;for(x;x>0;x--)for(y=0;y<100;y++);}
unsigned char keyscan(void)//¼üÅÌɨÃèÖµº¯Êý{unsigned char i,j;P1=0x0f;//¼ì²éÊÇ·ñÓмü°´ÏÂif(P1!=0x0f)//±íʾÓа´¼ü°´Ï { delay(1); //È¥¶¶ if(P1!=0x0f) for(i = 0;i < 4;i++) { P1 = key_scannum; if(P1 != key_scannum)//´ËÐÐÓмü°´ÏÂfor(j = 0;j < 16;j++){ if(P1 == table[j]) { flag=1; return(j); } } } }while((P1 & 0x0f)<0x0f);return(0);}
void display(uint num){ uint ge,shi,bai,qian; qian=num/1000; P0=led[qian]; P2=0xf7; delay(1); P2=0xff;
bai=num%1000/100; P0=led[bai]; P2=0xfb; delay(1); P2=0xff;
shi=num%100/10; P0=led[shi] & 0x7f; P2=0xfd; delay(1); P2=0xff;
ge=num%10; P0=led[ge]; P2=0xfe; delay(1); P2=0xff; }
void main(void){uint que,num=0;while(1){ que=keyscan(); if(flag==1) { num=num*10+que; flag=~flag; }display(num);}}是哪里有问题?各位大神帮忙看一下
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
不想为别人提供一点方便的人,怎么帮?!
一周热门 更多>