Trích:
Nguyên văn bởi sonduy1
#INT_TIMER1
void ngat_timer1()
{ int time=0,count=0;
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
set_timer1(24280);
time++; // timer 1 tràn sau ==> 500 000 us = 0.5s
if(time==2) // 2* 500 000 =1s
{
count++;
if(count==1)
{ portb=bang_ma[n1];
output_low(pin_d0);//mo transistor để led7 doan dc cap 5v(dung anot chung)
}
if(count==2)
{ portb=bang_ma[n2];
output_low(pin_d1);//tuong tu o d0
}
if(count==3)
{ portb=bang_ma[n3];
output_low(pin_d3);//
}
if(count==4)
{ portb=bang_ma[n4];
output_low(pin_d4);//
}
count=0;
}
enable_interrupts(int_timer1);
enable_interrupts(global);
}
bác coi giup sau e thực hiên quét mà kô dc.
|
Mấy dòng này bạn phải để trong void main() chứ:
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
set_timer1(24280);
enable_interrupts(int_timer1);
enable_interrupts(global);
Với lại hàm if, mấy cái sau bạn thử dùng else if xem sao. Chứ if thì có thể nó sẽ bị lẫn lộn đó.