![]() |
|
![]() |
#1 |
Nhập môn đệ tử
Tham gia ngày: Nov 2010
Bài gửi: 5
: |
![]() huhu.mấy a xem lại dùng e đoạn code này dùm nha.e điều khiển portc có ngắt TRR0.điều khiển led chạy từ phải sang trái từ chậm dần sang nhanh dần.dịch thì đúng nhưng chỉ sang có 1 led ah help!!!!!!
chương trinh e viết bằng ngôn ngữ c #include <16F877a.h> #fuses NOWDT,PUT,HS,NOPROTECT #use delay(clock=4000000) #byte portc=0x07 ///khai bao dia chi portb int16 count; int8 a; int j; //Chuong trinh ngat TMR0 #int_timer0 void interrupt_timer0() { set_timer0(0); ++count; if(count==560) { count=0; if(a==1) { while(1) { for(j=0;j<8;j++) { portc=1<<j; // dich trai a 1bit delay_ms((j+1)*50); } } } } } //Chuong trinh chinh main() { set_tris_c(0); set_tris_b(0); enable_interrupts(global); enable_interrupts(int_timer0); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_2); set_timer0(0); count=0; a=1; while(true) { portc=a; } } |
![]() |
![]() |
![]() |
#2 |
Nhập môn đệ tử
Tham gia ngày: Nov 2010
Bài gửi: 5
: |
sao ko ai giup vay???????
|
![]() |
![]() |
![]() |
#3 |
Đệ tử 7 túi
Tham gia ngày: May 2005
Bài gửi: 258
: |
thử như này xem sao:
[code] #include <16F877a.h> #fuses NOWDT,PUT,HS,NOPROTECT #use delay(clock=4000000) #byte portc=0x07 ///khai bao dia chi portb int16 count; int8 a; int j; //Chuong trinh ngat TMR0 #int_timer0 void interrupt_timer0() { set_timer0(0); ++count; if(count==560) { count=0; if(a==1) { for(j=0;j<8;j++) { portc <<=1 // dich trai a 1bit delay_ms((j+1)*50); } } } } //Chuong trinh chinh main() { set_tris_c(0); set_tris_b(0); enable_interrupts(global); enable_interrupts(int_timer0); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_2); set_timer0(0); count=0; a=1; while(true) { portc=a; } }
__________________
viết chương trình cho vdk chạy ổn định là cả một vấn đề. |
![]() |
![]() |
![]() |
#4 |
Nhập môn đệ tử
Tham gia ngày: Nov 2010
Bài gửi: 5
: |
thanks a nhiu
|
![]() |
![]() |