Wikipédia de RayMind

Arduino librairie buttons

De RayMind wiki
Révision datée du 15 février 2012 à 21:42 par Ray (discussion | contributions)
Aller à : navigation, rechercher

librairies/buttons/examples/sandbox

sandbox.ino

#include <buttons.h>

Button B;

void setup() {
   B.setMode(OneShotTimer);   // Return "ON" first (as a OneShot),
   B.setTimer(1500);         // then after 1.5 seconds, return "Hold".
   B.setRefresh(500);         // Return Hold every 500ms
}

void loop() {
   switch (B.check()) {
      case ON:
         // Do something on first press (oneshot)
         break;
      case Hold:
         // Do something every 500 ms
         break;
      default:
         break;
   }
}