MIDI Piano LED strip

Hi all! I'm hoping to find a code for a MIDI-reactive LED strip, where a note on a piano lights one or two LEDs responding to pitch=color and velocity=brightness. My coding experience is very limited, so any suggestions of code I could use are very much appreciated!

Sample project: https://youtu.be/eQD_4hWNx4A
Equipment: Esp32, WS2812B (144 LEDs), Arduino IDE

does your piano have a MIDI output you can tap into ?

It does! I'm using a MIDI to USB cable to connect my piano to a computer and from there it goes to the controller and LED strip.

the controller is the Arduino ? does your computer relay the MIDI info to the arduino already?

I'm using an Esp32 controller. I haven't yet set up the esp32 to receive the midi information, I assume that would all be in the code I upload to the controller, right?

the question was more how do you plan to relay the information from the PC to the ESP32 ? does your software do that? which communication channel will be used ? what's the protocol / format ?

That does sound like going the long way around really. Midi to ledstrip signal can be done without the interference of a computer, and it's simpler. Even if you have to split the midi signal before the computer it's easier to bypass that thing (and quicker, less latency / lag)

1 Like

Those are good points. Thank you @Deva_Rishi and @J-M-L
I honestly have very little experience in this area, in case it isn't obvious :upside_down_face:, so any guidance on how to approach this would be very helpful. Thank you!

agree with @Deva_Rishi

connect the MIDI output of your keyboard directly to an Arduino - see for example Notes and Volts: MIDI for the Arduino - Reading MIDI CC Messages

As @Deva_Rishi said, it is probably simpler to go straight from the Midi Din to the microcontroller.
I would suggest the following course of action :

  • study a bit the wiring from Din (piano) to serial (mcu) from the Midi foundation
  • try it, using the Midi library to see if you manage to receive correctly midi signals
  • add a few led, on the receiving of a midi signal do something, start simple and improve it as you get more and more confident!

I was just wondering, if your Piano doesn't really need the Computer at all ? I mean it plays sound by itself right. Just to make sure, not even that it matters all that much, midi is very easily splitable.

I have another question here, i somehow suspect you are intending to use addressable LED's, if so, your choice of MCU becomes quite relevant, since bit-banging the Ledstrip signal will turn off interrupts for a significant time which will not just cause swSerial to malfunction, but will also cause issues on hwSerial.

or making the right choice of addressable leds. I use APA102 just for this reason, they are more expensive than so called "neopixels" but don't require the same precise timing as the clock is managed on the strip.

2 Likes

They are or can be addressed faster as well. I use neopixels, it is what we started out with, and therefore let's us combine objects more freely.

yes, works really well with hardware SPI

J-M-L, @Deva_Rishi, @tomcombriat, thanks again for your input. As I read through your responses I realize how much I need to learn in order to make this work.

Since this is for an upcoming project, I won't be able to learn how to do all this from scratch on short notice. Do you have any recommendations of github repositories or other resources that I can refer to that would have a preexisting code and setup I can follow?

Thank you again for your time!

I don’t know of a good tutorial doing exactly what you need. Your Google foo is likely as good as mine….

Study the code from post 9 and build something similar so that you get the piano ➜ arduino communication going and that you receive the midi events..

Once this is done study how to blink LEDs in an asynchronous way using millis so that you don’t lock things up.
So look at

Once you get that play a bit with your strip’s library of choice (adafruit or fastled) to understand how things work

Then you put everything together

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.