Go Down

Topic: Arduino MEGA weird MIDI signals! (Read 131 times) previous topic - next topic

MikiL

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???

Code: [Select]
#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);
}

MikiL

Update... Looklike problem is digital pins. All digital pins have same problem, But code with analog pins work's just fine... If I put in code one potentiometer (analog) and one button (digital) analog work good but right at that moment when connecting button to Digital input, midi sending starts.

Grumpy_Mike

Quote
I have tried to find everywhere the answer for problem but can't find anything.
And you won't find one here unless you post your schematic.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy