Limiting time for keypress code.

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
unbound
 
Posts: 18
Joined: Sun Jan 12, 2014 9:51 pm

Limiting time for keypress code.

Post by unbound »

I am working on my first project, and it involves a keypad. Beginner programmer too.
I wrote a routine where a user presses a key to start data entry, a keycode is entered, and another key is pressed to finish the entry. The Arduino Uno then goes back to monitoring temperatures.
The design is often seen in systems where you have to press *(pin)# to open a gate.

The issue is how to 'timeout' if the '#' key is not pressed in a certain amount of time, so the controller can exit the keypress sequence and resume its regular routine.

Any suggestions?

User avatar
adafruit_support_mike
 
Posts: 67391
Joined: Thu Feb 11, 2010 2:51 pm

Re: Limiting time for keypress code.

Post by adafruit_support_mike »

There are several ways to solve that problem, some more complicated than others.

The most beginner-friendly version is probably based on the same ideas used in the "Blink Without Delay" example from the Arduino Playground: http://arduino.cc/en/Tutorial/BlinkWithoutDelay

The general principle involves converting a 'blocking' operation (one that won't let you do anything else until it's done) to a 'non-blocking' equivalent (one that checks to see if it should do something, but then lets you do other things if the answer is no).

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

Re: Limiting time for keypress code.

Post by adafruit_support_bill »

See this project for some code that is very similar to what you are looking for: http://learn.adafruit.com/biometric-sec ... m-and-test

User avatar
unbound
 
Posts: 18
Joined: Sun Jan 12, 2014 9:51 pm

Re: Limiting time for keypress code.

Post by unbound »

Thank you for the info!

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

Return to “Arduino”