hmm... that doesn't seem to have worked.
it's just working as a momentary again
This is what I've uploaded: -
#include <MIDI.h>
#include <midi_Defs.h>
#include <midi_Message.h>
#include <midi_Namespace.h>
#include <midi_Settings.h>
MIDI_CREATE_DEFAULT_INSTANCE();
const int buttonPin = 2;
int buttonState = 0;
int lastButtonState = 0;
int toggleState = 0;
void setup() {
MIDI.begin(1);
pinMode(buttonPin, INPUT_PULLUP);
}
void loop() {
buttonState = digitalRead(buttonPin);
if(buttonState != lastButtonState && buttonState == 1 && toggleState == 0) {
MIDI.sendControlChange(1, 127, 1);
toggleState = 1;
}
if(buttonState != lastButtonState && buttonState == 0 && toggleState == 1) {
MIDI.sendControlChange(1, 0, 1);
toggleState = 0;
}
lastButtonState = buttonState;
}