一,電路原理
?本電路實(shí)現(xiàn)了0—16的正計(jì)時(shí)呵恢,每2秒進(jìn)一位鞠值,逢16歸0.
二,電路原理圖
三渗钉,程序
#include <REGX51.H>
#define uchar unsigned char
#define uint unsigned int
uchar counter =0;
uchar i=0;
uchar code SEG[16]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
void timer0(void) interrupt 1 using 0
{
TH0=-50000/256;
TL0=-50000%256;
counter++;
if(counter==40)
{
counter=0;
if(i==16)
i=0;
else
i++;
P0=SEG[i];
}
}
void main(void)
{
P2=0x6f;
P0=SEG[0];
TMOD=0x01;
TH0=-50000/256;
TL0=-50000%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{;}
}
四齿诉,小結(jié)
?今天學(xué)習(xí)了倒計(jì)時(shí)器的設(shè)計(jì)與制作,然后進(jìn)行燒錄晌姚,看見(jiàn)計(jì)時(shí)器上有不同的變化,有點(diǎn)小成就感歇竟。在寫(xiě)ABCD的時(shí)候會(huì)算錯(cuò)挥唠,然后進(jìn)過(guò)同學(xué)幫忙最終成功了,還是開(kāi)心的焕议。