I have going on project of midi controller... And I have big trouble with it. This problem occurs every code what I try.
This is what happened...
I upload the code bellow in arduino and connect the pushbutton in pin 2. Midi data start sending signal rightaway without stopping ON, OFF, ON, OFF, ON, OFF, ON, OFF, ON, OFF,.... (well there is delay(1);).
I press the button and signal stops. Then I take arduino from table and place it on my hand and put finger like that it touch to Pin two, same pin where pushbutton is and Midi start working RIGHT.
I have tried to find everywhere the answer for problem but can't find anything.
Same thing happening midi shield and hairless-midi. I have tried to change baud rates but no luck. Is this some kind of grounding problem or is my arduino just broken?
Is there somebody who can help me with this???
#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();
int pushButton2 = 2;
int buttonState2 = 0;
int note2 = 0;
void setup() {
MIDI.begin(4);
Serial.begin(31250);
//Serial.begin(115200); //for heirless-midi
pinMode(pushButton2, INPUT);
}
void loop() {
int buttonState2 = digitalRead(pushButton2);
// Button 2
if (buttonState2 == HIGH) {
if (note2 == 0) {
MIDI.sendNoteOn(63,127,1);
note2 = 1;
}
} else {
if (note2 == 1) {
MIDI.sendNoteOff(63,0,1);
}
note2 = 0;
}
delay(1);
}