第2个回答 2012-10-28
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00};//0-f
uchar disbuf[4] = {0};
void display(){
static uchar com = 0;
P2 = 0;
P0 = table[disbuf[com]];
P2 = (1 << com);
com = (com+ 1) % 4;
}
void delay(int n){
...
}
void main()
{
disbuf[0] = 0;
disbuf[1] = 1;
disbuf[2] = 2;
disbuf[3] = 3;
while(1){
display();
delay(100);
}
}本回答被网友采纳