單片機LED燈BCD碼格式顯示00~59簡易密碼秒表程序
代碼如下:
//采用BCD碼格式顯示00~59簡易密碼秒表程序
#include
void delay1s() {
unsigned char i;
TMOD = 0x00;
for (i=0; i<0xc8; i++) {
TH1 = 0x63;
TL1 = 0x18;
TR1 = 1;
while(!TF1);
TF1 = 0;
}
}
void main () {
unsigned char i, t;
// TMOD = 0x10;
while (1) {
for (i=0; i<60; i++) {
t = (((i/10)<<4) | (i));
P1 = ~t;
delay1s();
}
}
}
評論