Controlling LEDs with midi and some general questions

I want to build my own lighting controller for my band and im having trouble understanding the midi library. been searching online for a while but most sketches seem to be more about playing midi notes. I’ll post a modified sketch i found online.

My apologies for not giving credit, I’m not trying to plagiarize someone else’s code, but i was googling things for hours last night and cant remember where i found the sketch. i added the NoteOff part but have no idea how to set the midi channel and note. My goal is to run at least 4 leds off a midi signal sent from my laptop on a specific channel so i can program the lights from my DAW and have them in sync with the music.

Also with this project i keep hitting the same wall trying to tech myself the Arduino language. i don’t know programming but have been reading a book on C++ and Getting Started with Arduino, but i still have no idea whats needed to accomplish something in a sketch, for instance i read up on the Reference about midi callbacks, but it doesn’t explain how to use them. only a list and the most basic idea of how they’re used. great for a programmer but the vast majority of it is gibberish to me. I’ve accomplished a few simple things like controlling leds and servos with switches or pots, but every time i find a sketch similar to what i want to do the programming styles are different from the rest so its hard to pick out the important parts. At times I work on projects till i get a headache. and have no idea how to move forward. I could use some advice on that as well.


here’s the code im trying to work with:

#include <MIDI.h>  // Add Midi Library

#define LED 13    // Arduino Board LED is on Pin 13

// Below is my function that will be called by the Midi Library
// when a MIDI NOTE ON message is received.
// It will be passed bytes for Channel, Pitch, and Velocity
void MyHandleNoteOn(byte channel, byte pitch, byte velocity) {
  digitalWrite(LED,HIGH);  //Turn LED on
  if (velocity == 0) {//A NOTE ON message with a velocity = Zero is actualy a NOTE OFF
    digitalWrite(LED,LOW);//Turn LED off

void MyHandleNoteOFF(byte channel, byte pitch, byte velocity) {
  digitalWrite(LED,LOW);  //Turn LED on
  if (velocity == 0) {//A NOTE ON message with a velocity = Zero is actualy a NOTE OFF
    digitalWrite(LED,LOW);//Turn LED off
void setup() {
  pinMode (LED, OUTPUT); // Set Arduino board pin 13 to output
  MIDI.begin(MIDI_CHANNEL_OMNI); // Initialize the Midi Library.
// OMNI sets it to listen to all channels.. MIDI.begin(2) would set it
// to respond to channel 2 notes only.
 MIDI.setHandleNoteOff(MyHandleNoteOFF); // This is important!! This command
  // tells the Midi Library which function I want called when a Note ON command
  // is received. in this case it's "MyHandleNoteOn".

void loop() { // Main loop; // Continually check what Midi Commands have been received.