硬 件连接:
P2口接行列按键,P0口接数码显示管,
下面是源码,不知道怎么没反应
#include <reg52.h>
unsigned char code table[4][4]={
{0Xc0,0xf9,0xa4,0xb0},{0x99,0x92,0x82,0xf8},{0x80,0x90,0x88,0x83},{0xc6,0xa1,0x86,0x8e}};
unsigned char a=0,b=0;
sbit l1=P2^0; //行号1
sbit l2=P2^1; //行号2
sbit l3=P2^2; //行号3
sbit l4=P2^3; //行号4
sbit h1=P2^4; //列号1
sbit h2=P2^5; //列号2
sbit h3=P2^6; //列号3
sbit h4=P2^7; //列号4
unsigned char x[4],y[8];
sbit duan1=P1^0;
sbit duan2=P1^1;
sbit duan3=P1^2;
sbit duan4=P1^3;
void display(unsigned char c,unsigned char d)
{
P0=table[c,d];
}
void scankeybord()
{ //将p2口的值按位送入行列
x[0]=l1;