#define F_CPU 16000000UL
#include <avr/io.h> // Most basic include files
#include <util/delay.h>
#include <avr/interrupt.h> // Add the necessary ones
#include <avr/signal.h> // here
volatile unsigned char state = 0;
// ***********************************************************
// Main program
//
int main(void) {
// variable initialize
EIMSK |= 1<<INT0;
EICRA = 0x02;
PORTD |= 1<<INT0;
DDRA |= 1<<PA0;
sei();
while(1) { // Infinite loop; define here the
// user Define Here
// end
}
}
ISR(INT0_vect)
{
if(state == 0)
state = 1;
else if(state > 0)
state = 0;
PORTA = ~state;
}
안녕하세요
화이트앳입니다.~
인터럽트 처리에서 PINA의 값을 읽어 비교하시면 됩니다.
아래와 같은 형식으로 진행하시면 될거 같습니다.
ISR(INT0_vect)
{
if(PINA & 0x01 == 0x01)
PORTA = 0x01;
else
PORTA = 0x00;
}