#include <16f877a.h>
#fuses hs,nolvp,nowdt//hs khai bao thach anh >=4mhz.
#use delay(clock=4M)
int i;
int bangma[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xf8,0x80,0x9 0};
int hc,hdv;
void main()
{
set_tris_a(0b00000000);
set_tris_b(0b00000000);
set_tris_c(0b00000000);
set_tris_d(0b00000000);
while (1)
{
hc=i/10;
hdv=i%10;
for(i=0;i<10;i++)
{
output_low(pin_c0);
output_high(pin_c1);
output_b(bangma[hdv]);
delay_ms(100);}
for(i=0;i<10;i++)
{
output_low(pin_c1);
output_high(pin_c0);
output_b(bangma[hc]);
delay_ms(100);
}
}
EM VIẾT NHƯ VẬY MÀ SAO NÓ CHỈ CHẠY CHO 1 BÊN LED CÒN BÊN KIA THÌ KO CHẠY ĐƯỢC, EM MỚI TẬP VIẾT CODE, MONG CÁC TIỀN BỐI GIÚP EM
#fuses hs,nolvp,nowdt//hs khai bao thach anh >=4mhz.
#use delay(clock=4M)
int i;
int bangma[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xf8,0x80,0x9 0};
int hc,hdv;
void main()
{
set_tris_a(0b00000000);
set_tris_b(0b00000000);
set_tris_c(0b00000000);
set_tris_d(0b00000000);
while (1)
{
hc=i/10;
hdv=i%10;
for(i=0;i<10;i++)
{
output_low(pin_c0);
output_high(pin_c1);
output_b(bangma[hdv]);
delay_ms(100);}
for(i=0;i<10;i++)
{
output_low(pin_c1);
output_high(pin_c0);
output_b(bangma[hc]);
delay_ms(100);
}
}
EM VIẾT NHƯ VẬY MÀ SAO NÓ CHỈ CHẠY CHO 1 BÊN LED CÒN BÊN KIA THÌ KO CHẠY ĐƯỢC, EM MỚI TẬP VIẾT CODE, MONG CÁC TIỀN BỐI GIÚP EM
![Smilie](http://dientuvietnam.net/forums/images/smilies/smile.gif)
Comment