HI,
I’ve done many search, and just can’t find the answer.
I’m trying to use 2 arduino nano (potentially 5) to communicate each other with MIDI.
I want to use MIDI communication to send NoteOn to control leds by switch on other nano. And vice-versa….
for now , i’m only starting to test communication between 2 nano to setup my basic.
code for the sender:
#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();
#define LED 13
int TEST;
//int note;
//int velocity;
//int channel;
int NIGHTSW;
int NIGHTStatus;
int LASTNIGHTStatus;
int NIGHTOUT;
int MASTERSW;
int MASTERStatus;
int LASTMASTERStatus;
int MASTEROUT;
void HandleNoteOn(byte channel, byte note, byte velocity) {
if (note == 1) {
digitalWrite(MASTEROUT, velocity * 2);
}
}
void setup() {
Serial.begin(31250);
MIDI.begin(MIDI_CHANNEL_OMNI);
TEST = 11;
pinMode(TEST, OUTPUT);
MASTEROUT = 8;
pinMode(MASTEROUT, OUTPUT);
MASTERSW = 12;
pinMode(MASTERSW, INPUT_PULLUP);
MIDI.setHandleNoteOn(HandleNoteOn);
}
void loop() {
MIDI.read();
MASTERStatus = digitalRead(MASTERSW);
if (MASTERStatus != LASTMASTERStatus) {
if (MASTERStatus == HIGH){
digitalWrite(MASTEROUT, HIGH);
MIDI.sendNoteOn(1, 1, 127);
digitalWrite(LED, HIGH);
delay(250);
digitalWrite(LED, LOW);
}
else {
digitalWrite(MASTEROUT, LOW);
MIDI.sendNoteOn(1, 1, 0);}
digitalWrite(LED, HIGH);
delay(250);
digitalWrite(LED, LOW);
}
LASTMASTERStatus = MASTERStatus;
digitalWrite(TEST, HIGH);
}
code for the receiver
#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();
#define LED 13
int TEST;
//int note;
//int velocity;
//int channel;
int NIGHTSW;
int NIGHTStatus;
int LASTNIGHTStatus;
int NIGHTOUT;
int MASTERSW;
int MASTERStatus;
int LASTMASTERStatus;
int MASTEROUT;
void HandleNoteOn(byte channel, byte note, byte velocity) {
if (note == 1) {
digitalWrite(MASTEROUT, velocity * 2);
}
}
void setup() {
Serial.begin(31250);
MIDI.begin(MIDI_CHANNEL_OMNI);
TEST = 4;
pinMode(TEST, OUTPUT);
MASTEROUT = 6;
pinMode(MASTEROUT, OUTPUT);
TEST = 8;
pinMode(TEST, OUTPUT);
MIDI.setHandleNoteOn(HandleNoteOn);
}
void loop() {
MIDI.read();
digitalWrite(TEST, HIGH);
}
i’ve connected the TX from the sender to the RX of the receiver and TX from the receiver to the RX of the sender.
so far, my led on the sender respond to the switch, but the led on the receiver have no reaction…
suggestion?
