Beginner Concepts: We’re Gonna Let You Finish, But First This Tutorial On Arduino Interrupts

OK, year-old pop culture references aside [Kyle] dropped us a line to show us his tutorial on using interrupts with your Arduino. Given the single core nature of your average Arduino’s AVR you pretty much have two choices for monitoring occasional un-timed inputs: Either check an input at an interval (which risks missing the signal entirely) or set up an interrupt to pause the chip’s normal operation. Obviously working with interrupts saves you tons of clock cycles since you are not polling a pin over and over. [Kyle] plans on a follow up tutorial to cover timer based interrupts, which can come in handy when generating frequencies and stuff.

Looking for more Arduino Basics? How about Basic on an Arduino. Check out our other beginner concepts posts as well if you need to work on your fundamentals.

13 thoughts on “Beginner Concepts: We’re Gonna Let You Finish, But First This Tutorial On Arduino Interrupts

  1. Am I the only one here finding AVR interrupts overly complicated?
    It’s a really good thing to have Arduino taking care of them (although with it’s own limitations).
    Thumbs up for the tutorial: I’m going to print for future reference.

    Also, I didn’t know about this meme and thought you needed a weirdly-shaped inductor to program ATTinys. Man, those are really ugly glasses.

    1. Setting up interrupts are indeed a little complicated. Looking at the tutorial the AVR is actually on the low side of complexity. ARM chips have a fairly complicated initialization.

      They can all be broken down to ALAC.

      Activate the timer.
      Load the values
      Arm the interrupts
      Clear the flags

    2. Interrupt driven design is an excellent practice that most people should start using after learning microcontrollers.

      Typically your “main” function should just initialize everything then run in a while(1) loop with it calling your microcontrollers “waitforinterupt” routine. This can possibly save loads of power.

  2. The next ‘Beginning Concepts’ article should feature My Little Pony.

    This is a fairly good read. I agree with The Longhorn Engineer, in that this is one of the core concepts of micro-controller programming, let alone AVRs. Interrupts are, in essence, what allow such a simple device to act like it’s multitasking. The interrupts on AVRs save soooooo much time, both in programming and actually *running* the program, and make it easier to do more with less.

  3. Hey all,

    Thanks for the awesome feedback (and thanks to Hackaday for featuring our post)! Interrupts are definitely a step into more advanced territory, but as Steve-O-Rama says above, they actually make life easier when you want to do more.

    Plus, we’ve found that once you get past all of the setup, you don’t have to touch most of it again, and can adapt a few code skeletons to do lots of different things.

    If anyone wants to see other Arduino or AVR tutorials on our site, drop us a line. Till then, thanks for stopping by!

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.