#include <reg51.h>
unsigned char code SEG_CODE[] = {
0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07,
0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71
};
sbit WEI1 = P2^0;
sbit WEI2 = P2^1;
sbit WEI3 = P2^2;
void EX0_Init() {
IT0 = 1
EX0 = 1
EA = 1
}
void Delay(unsigned int x) {
unsigned int i, j;
for (i = 0; i < x; i++)
for (j = 0; j < 110; j++);
}
void Display(unsigned char num1, unsigned char num2, unsigned char num3) {
WEI1 = 0;
P0 = SEG_CODE[num1];
Delay(1000);
WEI1 = 1;
WEI2 = 0;
P0 = SEG_CODE[num2];
Delay(1000);
WEI2 = 1;
WEI3 = 0;
P0 = SEG_CODE[num3];
Delay(1000);
WEI3 = 1;
}
void EX0_ISR() interrupt 1 {
Display(9, 0, 3);
}
void main() {
EX0_Init();
while (1) {
}
}