Reactive LED Strip Using MIDI Keyboard (code)

Struggling to create a code that uses MIDI (keyboard) to activate an LED on an Adafruit Dotstar strip.

Equipment:

Arduino Uno
Adafruit DotStar LED Strip (suggested by many for this type of project)
Roland RD 700 Keyboard (MIDI)

The keyboard is connected to a MIDI Input Circuit which sends data to the Arduino. Configurations seem correct - strandtest works and LED on the Arduino responds to keys when I run this MIDI input test:

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

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

//Create an instance of the library with default name, serial port and settings
MIDI_CREATE_DEFAULT_INSTANCE();

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 notes on channel 2 only.
  MIDI.setHandleNoteOn(MyHandleNoteOn); // This is important!! This command
  // tells the Midi Library which function you want to call when a NOTE ON command
  // is received. In this case it's "MyHandleNoteOn".
  MIDI.setHandleNoteOff(MyHandleNoteOff); // This command tells the Midi Library 
  // to call "MyHandleNoteOff" when a NOTE OFF command is received.
}

void loop() { // Main loop
  MIDI.read(); // Continuously check if Midi data has been received.
}

// MyHandleNoteON is the 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
}

// MyHandleNoteOFF is the function that will be called by the Midi Library
// when a MIDI NOTE OFF message is received.
// * A NOTE ON message with Velocity = 0 will be treated as a NOTE OFF message *
// It will be passed bytes for Channel, Pitch, and Velocity
void MyHandleNoteOff(byte channel, byte pitch, byte velocity) { 
  digitalWrite(LED,LOW);  //Turn LED off
}

I've clicked on every link I can find related to this topic. Many projects are similar, but the code seems to vary. The code for this is probably simple to most but I'm very new to it.
Any guidance on how to code the strip to respond to the MIDI keyboard would be greatly appreciated!

You need to change MyHandleNoteOn() and MyHandleNoteOff() do do what you want. Currently, they just turn the build-in LED on/off. Replace that code with whatever code you need to turn the dotstar strip on/off of whatever.

Thank you for that! Now I can hit any key and light that specified led.

void loop() { // Main loop
  MIDI.read(); // Continuously check if Midi data has been received.
}

// MyHandleNoteON is the 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) { 
  strip.setPixelColor(30, 0x0000ff);  //Turn LED on
  strip.show();  
}

void MyHandleNoteOff(byte channel, byte pitch, byte velocity) { 
  strip.setPixelColor(30, 0x000000);  //Turn LED off
  strip.show();  
}

What would be needed to have certain lights respond to MIDI notes?

The answer lies right there in the comments preceding MyHandleNoteOn() - read it.

You get passed in the value of the pitch and velocity so you will have to use them to determine what LEDs you want to affect and how. Most likely using if() statements..

void MyHandleNoteOn(byte channel, byte pitch, byte velocity) { 
  unsigned long color = 0;
  if ( pitch > 250 ) {
    color = 0x0000ff;
  } else if ( pitch > 200 ) {
    color = 0x00ff00;
  } else if ( pitch > 100 ) {
    color = 0xff0000;
  } else {
    color = 0x000000;
  }
  strip.setPixelColor(30, color);  //Turn LED on
  strip.show();  
}