【程序分析与设计】普中51单片机开发板采用2个4位一体共阴数码管,段选由P0控制,位选由P2.2-P2.4控制。使用开发板实现8个数码管从左到右动态显示0至7,即LED8~LED1八个数码管逐个显示0~7字符,不断循环。即:在两个4位一体数码管左数第1位显示0,过1秒,在左数第2位显示1,过1秒,在左数第3位显示2,过1秒,在左数第4位显示3 ,过1秒,在左数第5位显示4 ,过1秒,在左数第6位显示5 ,过1秒,在左数第7位显示6,过1秒,在左数第8位显示7 ,不断循环上述过程
uchar cod
uchar pos[] = {0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B};
voi
uchar i, j;
for (i = ms; i > 0; i--)
for (j = 110; j > 0; j--);
}
voi
uchar i = 0;
whil
P2 = pos[i];
P0 = seg[i];
delay_ms(1000);
i = (i + 1) % 8;
}
}