Advertisement
Guest User

Untitled

a guest
Feb 15th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <Bounce.h>
  2. #define BUTTON 2
  3. #define LED 13
  4.  
  5. #define BUTTON2 3
  6. #define LED2 12
  7.  
  8.  
  9. int ledValue = LOW;
  10. int ledValue2 = LOW;
  11.  
  12. Bounce bouncer = Bounce( BUTTON, 5 );
  13. Bounce bouncer2 = Bounce( BUTTON2, 5 );
  14.  
  15. void setup() {
  16.   pinMode(BUTTON,INPUT);
  17.   pinMode(LED,OUTPUT);
  18.  
  19.   pinMode(BUTTON2,INPUT);
  20.   pinMode(LED2,OUTPUT);
  21.  
  22. }
  23.  
  24. void loop() {
  25.    ligaLuz(bouncer,ledValue,LED);
  26.    ligaLuz(bouncer2,ledValue2,LED2);
  27. }
  28.  
  29. byte ligaLuz(Bounce b,int lV, int L)
  30. {
  31.   if ( b.update() ) {
  32.      if ( b.read() == HIGH) {
  33.        if ( lV == LOW ) {
  34.          lV = HIGH;
  35.        } else {
  36.          lV = LOW;
  37.        }
  38.        digitalWrite(L,lV);
  39.      }
  40.    }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement