den len tu o den 99
//chuong trinh dem len 00-99 hien thi tren led 7 doan
//portB noi voi cac doan a,b,c..h
//RC0,RC1 lam nhiem vu quet led
#include"16f877a.h"
#include"def_877a.h"
#use delay(clock=4000000)
//dinh nghia ma 7 doan
const char bangma[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};//tich cuc mucthap
//chuong trinh con hien thi
void hienthi(chuc7d,dv7d)
{
PORTB=chuc7d;
rC1=0;
delay_ms(50);
rC1=1;
PORTB=dv7d;
rC0=0;
delay_ms(50);
rC0=1;
}
//chuong trinh chinh
void main()
{
char j=0; //khai bao bien tinh
char chuc=0,dv=0;
char chuc7d,dv7d;
int i=0; // i la bien dem tu 0-99
// xac lap dau ra
trisb=0;
trisc0=0;
trisc1=0;
while (true)
{
while (i<=99)
{
chuc=i/10;
dv=i%10;
chuc7d=bangma[chuc];
dv7d=bangma[dv];
/* dung FOR tao mot vong lap de thuc hien chuong trinh hien thi
chuong trinh hien thi duoc thuc hien 20 lan*/
for(j=0;j<=20;j++) hienthi(chuc7d,dv7d);
i=i+1; //tang bien dem len 1
}
}
}
Bạn đang đọc truyện trên: AzTruyen.Top