Bạn chưa config cho portA, ko biết bạn dùng pic gì, bạn phải mắc thêm một điện trở kéo lên ở ra4. Chương trình của bạn mình thừ dùng cho pic16f877a sửa lại như sau:
Code:
void main() {
ADCON1=0x06; //config porta thanh digital in/out
PORTA = 0; // Initialize PORTA
TRISA = 0; // Configure PORTA as output
PORTB = 0; // Initialize PORTB
TRISB = 0; // Configure PORTB as output
PORTC = 0; // Initialize PORTC
TRISC = 0; // Configure PORTC as output
PORTD = 0; // Initialize PORTD
TRISD = 0; // Configure PORTD as output
while(1) {
PORTA = ~PORTA; // toggle PORTA
Delay_ms(1000); // one second delay
PORTB = ~PORTB; // toggle PORTB
Delay_ms(1000); // one second delay
PORTC = ~PORTC; // toggle PORTC
Delay_ms(1000); // one second delay
PORTD = ~PORTD; // toggle PORTD
Delay_ms(1000); // one second delay
}
}