NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » how to write a simple button push interrupt with debounding

December 25, 2009
by mathison
mathison's Avatar

Does anyone have any sample code for when a momentary contact switch closes - brings a pin high, triggers and interrupt and the gets debounced? and if the debounce is good - sets a port pin high.

I am having real trouble figuring out interrupts and debouncing.

thanks, joel

December 28, 2009
by hevans
(NerdKits Staff)

hevans's Avatar

Hi Joel,

I believe I pointed you to these in an email, but I'm going to also post them here for people who happen upon this post. We have several examples of interrupts sprinkled across our tutorials. The most comprehensive is found in our interfacing with a keyboard - interrupts tutorial this tutorial covers interrupts in general and has an example of pin change interrupts. For examples of timer interrupts you can refer to our led marquee tutorial

Although it is not explicitly explained in the tutorial we use a debounced button in our motors and microcontrollers tutorial. Check out the source code on that project for an example.

Humberto

Post a Reply

Please log in to post a reply.

Did you know that a piezoelectric buzzer can be used in reverse as a microphone? Learn more...