Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define MIN_LOCKOUT 10000
- int digitalInput;
- int oldState;
- int lockoutTimer;
- int countPresses;
- boolean lockedout=false;
- void setup(){
- Serial.begin(9600);
- }
- void loop(){
- if(lockedout){
- lockoutTimer++;
- if(lockoutTimer==MIN_LOCKOUT){
- lockedout=false;
- lockoutTimer=0;
- }
- } else {
- oldState=digitalInput;
- digitalInput=digitalRead(2);
- if(digitalInput==LOW&&oldState==HIGH){
- countPresses++;
- Serial.println(countPresses);
- }
- lockedout=true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement