本帖最后由 dongyumin 于 2013-10-4 19:10 编辑
#include<reg51.h>
#define uchar unsigned char
uchar wod0,wod = 16;
uchar code DSY_CODE[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,
0xF8,0x80,0x90,0x88,0x83,0xA7,0xA1,0x86,0x8E,0xFF};
uchar ming(void)
{
uchar k;
P2 = 0xF0;
k = P2;
switch(k)
{
case 0xe0: wod0 = 0 ; break;
case 0xd0: wod0 = 1 ; break;
case 0xb0: wod0 = 2 ; break;
case 0x70: wod0 = 3 ; break;
default: break;
}
P2 = 0xf0;
k = P2;
switch(k)
{
case 0x0e: wod = wod0 + 0 ; break;
case 0x0d: wod = wod0 + 4 ; break;
case 0x0b: wod = wod0 + 8 ; break;
case 0x07: wod = wod0 + 12 ; break;
default: break;
}
return wod;
}
void main(void)
{
while(1)
{
P2 = 0xf0;
if(P2 != 0xf0)
ming();
P0 = DSY_CODE[wod];
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>