fbpx
< Back

Interrupts are useful for automatically executing things in microcontroller programs and can solve timing problems. Good tasks for using an interrupt may include reading a rotary encoder or monitoring user input.
The Arduino Uno has 2 and the Mega has 6 external interrupt pins available:

  • Arduino Uno/Controllino MINI/INT.x interrupt:                   2/IN0/INT.0  –  3/IN1/INT.1 
  • Arduino Mega/Controllino MAXI,MEGA/INT.x interrupt: 2/D0/INT.0  –  3/D1/INT.1  –  18/IN0/INT.5  –  19/IN1/INT.4  –  20/SDA/INT.3  –  21/SCL/INT.2

On the other hand the pin change interrupts can be enabled on many more pins.

Hardware Required

  • Controllino MINI/MAXI/MEGA
  • 12/24V DC Power supply

Circuit

Note*
Pin header is working on 5V TTL levels. Voltage levels over 5.5V can damage the Controllino permanently.

Code

Controllino MINI/MAXI/MEGA

#include <Controllino.h>

const byte digital_output = CONTROLLINO_D0;
const byte interruptPin = CONTROLLINO_IN1;
volatile byte state = LOW;

void setup() {
 pinMode(digital_output, OUTPUT);
 pinMode(interruptPin, INPUT);
 attachInterrupt(digitalPinToInterrupt(interruptPin), blink, CHANGE);
}

void loop() {
 digitalWrite(digital_output, state);
}

void blink() {
 state = !state;
}

info_ua392tt9

This is a paragraph.It is justify aligned. It gets really mad when people associate it with Justin Timberlake. Typically, justified is pretty straight laced. It likes everything to be in its place and not all cattywampus like the rest of the aligns. I am not saying that makes it better than the rest of the aligns, but it does tend to put off more of an elitist attitude.