5 buttons control the same thing
Opened this issue · 1 comments
I am trying to use this debounce . only problem is , there is no button assignment, even though the addpin says ,
pinDebouncer.addPin(5, HIGH );
pinDebouncer.addPin(6, HIGH);
pinDebouncer.addPin(7, HIGH);
pinDebouncer.addPin(8, HIGH);
pinDebouncer.addPin(9, HIGH);
pinDebouncer.addPin(10, HIGH);
but the code im trying to write using different pins for different things
but when I upload just a sample of just one thing I want to do with one specific button , I can press any of the buttons one the breadboard , and it reads all the buttons, how do I fix this issue
Thank You
John
#include <SoftwareSerial.h>
#include "Adafruit_Soundboard.h"
#define SFX_TX 2
#define SFX_RX 3
#define SFX_RST 4
SoftwareSerial ss = SoftwareSerial(SFX_TX, SFX_RX);
Adafruit_Soundboard sfx = Adafruit_Soundboard(&ss, NULL, SFX_RST);
#if !defined(nullptr)
#define nullptr NULL
#endif
#include "FTDebouncer.h"
FTDebouncer pinDebouncer(30);
int btn1 = 5;
int btn2 = 6;
int btn3 = 7;
int btn4 = 8;
int btn5 = 9;
int btn6 = 10;
void setup(){
ss.begin(9600);
Serial.begin(57600);
// NOTE:
// INPUT_PULLDOWN is only supported by some microcontrollers
//pinDebouncer.addPin(3, LOW, INPUT_PULLDOWN);
pinDebouncer.addPin(btn1, HIGH );
pinDebouncer.addPin(btn2, HIGH);
pinDebouncer.addPin(btn3, HIGH);
pinDebouncer.addPin(btn4, HIGH);
pinDebouncer.addPin(btn5, HIGH);
pinDebouncer.addPin(btn6, HIGH);
digitalRead(btn1 = HIGH);
pinDebouncer.begin();
}
void loop(){
unsigned long us = micros();
unsigned long usElapsed;
pinDebouncer.update();
usElapsed = micros() - us;
Serial.println(usElapsed);
}
void onPinActivated(int =btn1){
sfx.playTrack("TAKEOMYHOGG");
}
void onPinDeactivated(int btn1){
Serial.print("Pin deactivated: ");
Serial.println(btn1);
}
this is the code