PIC Vietnam

PIC Vietnam (http://www.picvietnam.com/forum/index.php)
-   Các ngôn ngữ lập trình khác (CCS C, HT PIC,...) (http://www.picvietnam.com/forum/forumdisplay.php?f=12)
-   -   hic!!!!!!hic!!!!!!hic!!!!!! (http://www.picvietnam.com/forum/showthread.php?t=7686)

kakaculo123 07-01-2011 06:28 PM

hic!!!!!!hic!!!!!!hic!!!!!!
 
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;
}
}

kakaculo123 07-01-2011 09:40 PM

sao ko ai giup vay???????

tdm 08-01-2011 04:19 PM

Trích:

Nguyên văn bởi kakaculo123 (Post 41363)
sao ko ai giup vay???????

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;
}
}

kakaculo123 11-01-2011 11:45 AM

thanks a nhiu


Múi giờ GMT. Hiện tại là 03:16 PM.

Tên diễn đàn: vBulletin Version 3.8.11
Được sáng lập bởi Đoàn Hiệp.
Copyright © PIC Vietnam