4x4矩阵 出问题啦 高手来看看啊!
时间:10-02
整理:3721RD
点击:
#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];
}
}
刚搞懂啦 原来是P2赋值时候赋反了
谢谢lz,学习了哈哈哈哈哈哈哈哈哈