Introduction: Using Arduino Interrupts

Picture of Using Arduino Interrupts

In this simple project we will be taking a quick look at interrupts and how they work.

The idea of an interrupt is that it can be used to simulate two things running at the same time.

For example, a delay in the code for an Arduino would normally halt all other processes, but with an interrupt the delay can take place while something else is being done.

Step 1: Add LEDs

Picture of Add LEDs

1. Connect the 5V pin on your Arduino to the red power rail on your breadboard

2. Connect the GND pin on your Arduino to the blue ground rail on your breadboard

3. Connect all three colored LEDs to your Arduino using digital pins 13, 12, and 11

4. Use a 220 Ohm resistor to connect them in order to extend the lifespan of your LEDs

5. Ensure that all LEDs are properly grounded to the ground rail of the breadboard

Step 2: Connect the Button

Picture of Connect the Button

1. Connect the bottom left pin on the button to digital pin 2 on your Arduino

2. Use a 220 Ohm resistor to ground the button to the grounding rail in order to help prevent erratic readings

Warning: It is very important that you use digital pin 2 for the button since interrupts only work on certain pins!

Step 3: Upload the Code

1. Upload the attached code to your Arduino and you are good to go

Summary: The goal of this is to simply get a basic handle on how interrupts work. Once everything is properly set up the yellow LED should turn on or off every second and anytime the button is pressed it will interrupt the yellow LED delay to toggle which button (green or red) is on.

Comments

About This Instructable

108views

5favorites

Bio: I am a college student studying Information Technology
Add instructable to: