Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Bounce.h>
- #define BUTTON 2
- #define LED 13
- #define BUTTON2 3
- #define LED2 12
- int ledValue = LOW;
- int ledValue2 = LOW;
- Bounce bouncer = Bounce( BUTTON, 5 );
- Bounce bouncer2 = Bounce( BUTTON2, 5 );
- void setup() {
- pinMode(BUTTON,INPUT);
- pinMode(LED,OUTPUT);
- pinMode(BUTTON2,INPUT);
- pinMode(LED2,OUTPUT);
- }
- void loop() {
- ligaLuz(bouncer,ledValue,LED);
- ligaLuz(bouncer2,ledValue2,LED2);
- }
- byte ligaLuz(Bounce b,int lV, int L)
- {
- if ( b.update() ) {
- if ( b.read() == HIGH) {
- if ( lV == LOW ) {
- lV = HIGH;
- } else {
- lV = LOW;
- }
- digitalWrite(L,lV);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement