I just had a quick question on getting the arduino to do two things at once... or atleast making it appear to do two things at once. I have a display that i want to prompt a user to enter a password, but below the password i want a timer to display a countdown. We are trying to build a little arm/disarm prop for airsoft games but we want a timer on it as well. I can get the timer to work just fine... and i can get the password to work just fine. Then i try to smash them together and it doesn't work lol. What happens is the timer will time only when i hit a button on the keypad or the timer will time and the keypad will only type one letter every now n then. The problem is doing both at teh same time so i didn't know if there were ne tricks to bounce back n forth or will i ahve to pause the timer while entering the code on the key pad?
Is your timer based on delay()?
There is no reason that displaying a timer and getting keypresses at the "same" time can not be done.
yes it is delay based
i was using this guys example
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1269733228/4
for a simple timer
Im guessing the delay is what is screwing it up? It s having to wait that time period beforei can enter on the keypad...
Im guessing the delay is what is screwing it up?
Good guess. Correct, even.
Look at the Blink Without Delay example for clues how to not use delay.
Basically, the "timer" isn't real. There is a variable with a value in it. At appropriate times, on each pass through loop, the value is incremented (or decremented) - whenever millis() returns a value that is significantly different from some stored value (the last time the value was changed).
At appropriate places in the code, display the value in the variable.
Take a look at TimerOne on the playground, it is very easy to use.
thanks for the quick responses... i will give these two a try when i get home ... that is if the little lady doesn't have a list for me already. When i get it working or if i have more questions i'll post. Thanks again!