#include <avr/io.h>
#include <avr/interrupt.h>
#define LED_PIN 5
#define BUTTON_PIN 2
int main ()
{
DDRC = 1 << LED_PIN; //PC5 as an output
DDRD &= ~(1 << BUTTON_PIN); //PD2 as input
PORTD = 1 << BUTTON_PIN; //pull-up activated
EICRA = (1 << ISC01); //make INT0 falling edge triggered
EIMSK = (1 << INT0); //enable external interrupt 0
sei (); //enable interrupts
while (1) //wait here
{
// No code
}
return 0;
}
ISR (INT0_vect) //ISR for external interrupt 0
{
PORTC ^= (1 << LED_PIN); //toggle PORTB.5
}