rdbischoff
Member
Alright, simple buttons, a switch, and a TS input. At one point in my testing they worked just fine with the breadboard and the Teensy 2.0. One wire going to Digital Inputs (0,1,2,3), one to ground. The switch works when I test it again. The buttons and TS input however do not work correctly. They will send a signal through the Serial Monitor when I touch and "untouch" the alligator clip to the solder lugs. But when I connect the clip and press the button it doesn't send that signal like it should. I've included the code that I am using for them. Like I said the switch works but the buttons or sustain pedal don't. Any ideas on if it could be my physical buttons having a problem or if it is something in my code which is essentially the same for each?
Code:
#include <Bounce.h>
// Create Bounce objects for each button. The Bounce object
// automatically deals with contact chatter or "bounce", and
// it makes detecting changes very simple.
// (#, ##) ## = debounce time
Bounce button0 = Bounce(0, 10); // panic button
Bounce button1 = Bounce(1, 10); // switch for snares
Bounce button2 = Bounce(2, 10); // next patch button
Bounce button3 = Bounce(3, 10); // sustain pedal
// the MIDI channel number to send messages
const int channel = 1;
/////////////////////
////// SET UP ///////
/////////////////////
void setup() {
Serial.begin(9600);
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
}
////// LOOP /////
void loop() {
///// BUTTONS /////
button0.update();
button1.update();
button2.update();
button3.update();
/// ON ///
if (button0.fallingEdge()) {
usbMIDI.sendNoteOn(0, 127, channel);
Serial.println("Panic!!!");
}
if (button1.fallingEdge()) {
usbMIDI.sendNoteOn(1, 127, channel);
Serial.println("Switch!!!");
}
if (button2.fallingEdge()) {
usbMIDI.sendNoteOn(2, 127, channel);
Serial.println("Next!!!");
}
if (button3.fallingEdge()) {
usbMIDI.sendControlChange(64, 127, channel);
Serial.println("Sustain!!!");
}
/// OFF ///
if (button0.risingEdge()) {
usbMIDI.sendNoteOff(0, 0, channel);
Serial.println("Panic Off!!!");
}
if (button1.risingEdge()) {
usbMIDI.sendNoteOff(1, 0, channel);
Serial.println("Switch Off!!!");
}
if (button2.risingEdge()) {
usbMIDI.sendNoteOff(2, 0, channel);
Serial.println("Next Off!!!");
}
if (button3.risingEdge()) {
usbMIDI.sendControlChange(64, 0, channel);
Serial.println("Sustain Off!!!");
}
}