Time for more garbage nobody cares about. I wrote this great - TopicsExpress



          

Time for more garbage nobody cares about. I wrote this great debouncing function today, now I can finally use the buttons on my future alarm clock! If your not familiar with debounicng you can find more info here, but as far as I can tell, my script is a bit simpler then the one that Arduino suggests. arduino.cc/en/Tutorial/Debounce // create button check function boolean buttonRead(int idButton){ if (digitalRead(idButton) == HIGH){ buttonCount = millis(); if (millis() - buttonCount > buttonCountMax){ return true; } else{ return false; } } } void setup(){ // setup input pins pinMode(scButton,INPUT_PULLUP); pinMode(mnButton,INPUT_PULLUP); pinMode(hrButton,INPUT_PULLUP); } void loop(){ // incrament time if button is pressed if(buttonRead(scButton)){ sc+=1; } if(buttonRead(mnButton)){ mn+=1; } if(buttonRead(hrButton)){ hr+=1; }
Posted on: Mon, 30 Jun 2014 01:42:39 +0000

Trending Topics



Recently Viewed Topics




© 2015