Go Down

Topic: Keypad.getState() (Read 3529 times) previous topic - next topic


Mar 24, 2011, 06:05 pm Last Edit: Mar 24, 2011, 06:53 pm by davidino81 Reason: 1
I guys!
I wrote this piece of code but I'm not sure if it work fine. I cannot test it because I don't have the Arduino yet.

My doubt is about the while condition, if I hold on the button "*" the function getState() will be  "PRESSED" or after some time it will change in "HOLD" ?
Another question, if I push the button 1 and while I hold the button 1 I push the button 2, the getKey function will be 1 or 2 ?

Code: [Select]
void active(){
 Serial.print(" * has been pressed");
 flash(ledPin,100); //flash a led for 0.1 sec.
 unsigned long pressTime=millis();  
   if ((millis()-pressTime)>activationTime){
     Serial.println("The button * has been pressed for more than 2 sec");
     pressTime=millis(); //so, out of the if condition


Im sorry but i've tried it yesterday and it doesn't work. I'm not sure how to use the getState() function yet.
When i show the return of the function via Serial.println() it returns 0, probably because of the type of the variable, it returns a Keystate object and i cant find what's that.
Keep looking!

Go Up