66% or better

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.

Comments

  1. DS says:

    Internet memes? In my hackaday?

  2. NeXTWay says:

    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.

    • 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

    • 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.

  3. kb says:

    Nice tutorial, but what the heck is that white thing that looks like a pair of glasses on the chip? It’s not in the image on the jump page.

  4. Steve-O-Rama says:

    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.

  5. EngBlaze says:

    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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s