#include <MIDI.h> // Add Midi Library
#include <Adafruit_NeoPixel.h> // Add Led Library
//define NeoPixel Pin and Number of LEDs
#define PIN 6
#define NUM_LEDS 88
// strip.setPixelColor(4, 120, 255, 40);
// strip.setPixelColor(Number of LED, RedDensity, GreenDensity, BlueDensity);
#define RedDensity 150
#define GreenDensity 199
#define BlueDensity 88
//create a NeoPixel strip
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
//Create an instance of the library with default name, serial port and settings
MIDI_CREATE_DEFAULT_INSTANCE();
void setup() {
strip.begin(); // start the strip and blank it out
strip.show();
MIDI.begin(1); // Initialize the Midi Library on channel 1
Serial.begin(115200); // Hairless MIDI speed
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/Off are the functions that will be called by the Midi Library
// when a MIDI Note message is received.
// It will be passed bytes for Channel, Pitch, and Value
// It checks if the MIDI Note Pitch is within the Note Range 36 (C1) to 51 (D#2)
// If it is, it lights up the corresponding LED (LEDs 1 thru 16)
void MyHandleNoteOn(byte channel, byte pitch, byte velocity) {
switch (pitch) {
case 21:
strip.setPixelColor(1, RedDensity, GreenDensity, BlueDensity);
strip.show();
break;
case 22:
strip.setPixelColor(2, RedDensity, GreenDensity, BlueDensity);
strip.show();
break;
case 23:
strip.setPixelColor(3, RedDensity, GreenDensity, BlueDensity);
strip.show();
break;
case 24:
strip.setPixelColor(4, RedDensity, GreenDensity, BlueDensity);
strip.show();
break;
case 25:
strip.setPixelColor(5, RedDensity, GreenDensity, BlueDensity);
strip.show();
break;
case 26:
strip.setPixelColor(6, RedDensity, GreenDensity, BlueDensity);
strip.show();
break;
.
.
.
.
.
.
.
case 105:
strip.setPixelColor(85, RedDensity, GreenDensity, BlueDensity);
strip.show();
break;
case 106:
strip.setPixelColor(86, RedDensity, GreenDensity, BlueDensity);
strip.show();
break;
case 107:
strip.setPixelColor(87, RedDensity, GreenDensity, BlueDensity);
strip.show();
break;
case 108:
strip.setPixelColor(88, RedDensity, GreenDensity, BlueDensity);
strip.show();
break;
}
}
void MyHandleNoteOff(byte channel, byte pitch, byte velocity) {
switch (pitch) {
case 21:
strip.setPixelColor(1, 0, 0, 0);
strip.show();
break;
case 22:
strip.setPixelColor(2, 0, 0, 0);
strip.show();
break;
case 23:
strip.setPixelColor(3, 0, 0, 0);
strip.show();
break;
case 24:
strip.setPixelColor(4, 0, 0, 0);
strip.show();
break;
case 25:
strip.setPixelColor(5, 0, 0, 0);
strip.show();
break;
case 26:
strip.setPixelColor(6, 0, 0, 0);
strip.show();
break;
.
.
.
.
.
.
.
.
break;
case 104:
strip.setPixelColor(84, 0, 0, 0);
strip.show();
break;
case 105:
strip.setPixelColor(85, 0, 0, 0);
strip.show();
break;
case 106:
strip.setPixelColor(86, 0, 0, 0);
strip.show();
break;
case 107:
strip.setPixelColor(87, 0, 0, 0);
strip.show();
break;
case 108:
strip.setPixelColor(88, 0, 0, 0);
strip.show();
break;
}
}
i didnt paste cuz its too long(over 9k characters). but there is the code.