- 点亮数码管代码
cpp
#include <reg51.h>
void Delay(unsigned int n)
{
while (--n);
}
int main(void)
{
const unsigned char a[10] = {0X3F, 0X06, 0X5B, 0X4F, 0X66, 0X6D, 0X7D, 0X07, 0X7F, 0X6F};
int i = 0;
P1 = 0;
P1 |= (1 << 1);
P0 = 0;
for (i = 0; i < 10; i++)
{
P0 = a[i];
Delay(0xffff);
}
return 0;
}