Advertisement
otakus

Untitled

Nov 20th, 2012
9,235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. String keys="123A456B789C*0#D";
  2. int key;
  3. boolean key_lockout=false;
  4.  
  5. void setup(){
  6.    Serial.begin(9600);
  7. }
  8.  
  9. void loop(){
  10.   key=getKeypad();
  11.   if(key!=-1)
  12.       Serial.println(keys[key]);
  13.    delay(10);
  14. }
  15.  
  16. int getKeypad(){
  17.   int ret=-1;
  18.   boolean reset_lockout=false;
  19.   if(analogRead(A0)==0)
  20.     key_lockout=false;
  21.   else if(!key_lockout){
  22.     delay(20);
  23.     ret=15-(log((analogRead(A0)-183.9)/58.24)/0.1623)+0.5;
  24.     key_lockout=true;
  25.   }
  26.   return ret;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement