Task 1: Basic External Interrupt Usage

Task: Enable INT0 interrupt and pin change interrupt PCINT0 to light up one LED for each in their respective interrupt service routines.

  1. 1.Configure PORTA as output. To use the switches in the STK600 as interrupt source, enable pull-up on PORTB (for PCINT0) and PORTD (for INT0).
  2. 2.Configure INT0 to sense rising edge. Enable the interrupts INT0 and PCINT0, and set the global interrupt enable bit.
  3. 3.Inside the ISR of INT0, turn on LED0 and then turn off LED0 after some delay. Similarly for PCINT0, turn on and off LED1 with some delay in between.
Hardware Setup:
  1. 1.Connect PORTA header to the LED header on STK600 using a ten-wire ribbon cable.
  2. 2.Connect two wires; one between the pins SW0 and PD0, and the other between SW1 and PB0.

Without using STK600, connect two LED circuits as shown in Figure 1; one at PA0 and another at PA1, and two switch circuits, one at PD0 and another at PB0.

While running the example code when switch SW0 is pressed, due to pull-up the interrupt INT0 will be triggered when SW0 is released and LED0 blinks once. When switch SW1 is pressed the interrupt PCINT0 is triggered and LED1 blinks once, and when SW1 is released the interrupt PCINT0 is triggered once again and LED1 blinks once again. So a single switch action (press and release) on SW1 produces two blinks on LED1.