hi everyone, I have a project in progress, partly I have succeeded, my project is about sending SysEx midi message from Arduino Uno to my keyboard with a button and an LED and it works, but I want that if I press the button that does the same service on the kyeboard that send back the same message to the Arduino then the LED should light up or off .
the messages 23 bytes as follows:
F0 42 7F 60 01 01 10 7D 00 4E 00 00 00 00 00 00 00 00 00 00 00 00 F7
F0 42 7F 60 01 01 00 7D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F7
F0 42 7F 60 01 01 08 7D 00 00 4E 00 00 00 00 00 00 00 00 00 00 00 F7
F0 42 7F 60 01 01 00 7D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F7
Here is my code:
#include <MIDI.h>
#include <midi_Defs.h>
#include <midi_Message.h>
#include <midi_Namespace.h>
#include <midi_Settings.h>
static const unsigned SysExMaxSize = 256;
MIDI_CREATE_INSTANCE(HardwareSerial,Serial, midiOut); // create a MIDI object called midiOut
byte Coff[21] = {0x42,0x7F,0x60,0x01,0x01,0x10,0x7D,0x00,0x4E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
byte Con[21] = {0x42,0x7F,0x60,0x01,0x01,0x00,0x7D,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
int led = 13;
int button = 12;
int ledState = HIGH;
int buttonCurrent;
int buttonPrevious = LOW;
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(31250);
pinMode(button, INPUT);
pinMode(led, OUTPUT);
}
void loop()
{
buttonCurrent = digitalRead(button);
if (buttonCurrent == HIGH && buttonPrevious == LOW)
{
if (ledState == HIGH)
{
ledState = LOW;
midiOut.sendSysEx(21,Con, false);
}
else
{
ledState = HIGH;
midiOut.sendSysEx(21,Coff, false);
}
}
digitalWrite(led, ledState);
buttonPrevious = buttonCurrent;
}