sonvivant:
Also, further to a comment from Nick Gammon earlier in this thread, the buttons are on pull-down, not pull-up. (Is pull-up better and why?)void setup() {
MIDI.begin();
// initialize the pushbutton pin as an input:
pinMode(buttonStop, INPUT);
pinMode(buttonGo, INPUT);
pinMode(buttonLast, INPUT);
pinMode(buttonNext, INPUT);
}
...
The simplest thing is to have the buttons wired, from the pin to ground, so when you press it, the pin is grounded. To make this work you need pull-up, eg.
void setup() {
MIDI.begin();
// initialize the pushbutton pin as an input:
pinMode(buttonStop, INPUT_PULLUP);
pinMode(buttonGo, INPUT_PULLUP);
pinMode(buttonLast, INPUT_PULLUP);
pinMode(buttonNext, INPUT_PULLUP);
}
...
Now the (weak) pull-up keeps the pins high, and when you push the button they go low. So you look for a high -> low transition.