用C51写个代码,使一个七段数码管始终显示03.08.12.并且cpu是AT89C51.
时间: 2024-05-02 15:17:50 浏览: 87
```c
#include <regx52.h>
// 数码管共阳极接口连接
#define LED_PORT P0
// 数码管段选控制码
unsigned char LED_CODE[] = {
0xC0, // 0
0xF9, // 1
0xA4, // 2
0xB0, // 3
0x99, // 4
0x92, // 5
0x82, // 6
0xF8, // 7
0x80, // 8
0x90 // 9
};
void delay(unsigned int t) {
unsigned int i, j;
for (i = t; i > 0; i--)
for (j = 110; j > 0; j--);
}
void main() {
unsigned char i = 0;
while (1) {
// 显示03.08.12
LED_PORT = LED_CODE[0];
delay(5);
LED_PORT = LED_CODE[0];
delay(5);
LED_PORT = LED_CODE[1];
delay(5);
LED_PORT = LED_CODE[0];
delay(5);
LED_PORT = LED_CODE[8];
delay(5);
LED_PORT = LED_CODE[0];
delay(5);
LED_PORT = LED_CODE[1];
delay(5);
LED_PORT = LED_CODE[2];
delay(5);
}
}
```
阅读全文