Lesson 5 - Input Lockout/Async loop?

For makers who have purchased an Adafruit Starter Pack, get help with the tutorials here!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
lastcoolnameleft
 
Posts: 8
Joined: Sun Jul 25, 2010 1:46 am

Lesson 5 - Input Lockout/Async loop?

Post by lastcoolnameleft »

Hello,

First off, thank you very much for the lessons. They've helped me get from 0 -> "Whoo hoo!" in just a few nights.

One problem I've encountered after the end of lesson 5, is that sometimes pressing the button doesn't register a change. Looking at the code, it appears that this is due to a race condition of pressing the button while the Arduino is performing it's flashing sequence.

Is there a way of performing an asynchronous input loop? Or must everything be done serially?

Thanks,
-Tommy.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Lesson 5 - Input Lockout/Async loop?

Post by adafruit_support_bill »

You can use the AttachInterrupt function to attach an interrupt handler to one of the interrupt pins:

http://arduino.cc/en/Reference/AttachInterrupt

mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am

Re: Lesson 5 - Input Lockout/Async loop?

Post by mtbf0 »

it's less arduinish, but you can also snag one of the timer interrupts. all three timers start up when the arduino starts and they each overflow about once every millisecond. the timer0 overflow is used for the millis function, but the timer1 and timer2 overflows are there for the asking.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Starter Pack”