Advertisement
otakus

Untitled

Jul 3rd, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1.  
  2. #define MIN_LOCKOUT 10000
  3.  
  4. int digitalInput;
  5. int oldState;
  6. int lockoutTimer;
  7. int countPresses;
  8. boolean lockedout=false;
  9.  
  10. void setup(){
  11.   Serial.begin(9600);
  12. }
  13.  
  14. void loop(){
  15.   if(lockedout){
  16.     lockoutTimer++;
  17.     if(lockoutTimer==MIN_LOCKOUT){
  18.       lockedout=false;
  19.       lockoutTimer=0;
  20.     }
  21.   } else {
  22.     oldState=digitalInput;
  23.     digitalInput=digitalRead(2);
  24.     if(digitalInput==LOW&&oldState==HIGH){
  25.       countPresses++;
  26.       Serial.println(countPresses);
  27.     }
  28.     lockedout=true;
  29.   }  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement