Tuesday, November 4, 2008

Arduino LED MIDI Controller


It's been a while since I've made a post so I have decided that it was about time I did. This time I'll be talking about my Haunted House I made.

I started with the idea to take a Halloween decoration (small haunted house) and add some LEDs to it and make them blink. What I ended up with was a haunted house with 6 LEDs in it all controlled by MIDI. I used an Arduino to receive MIDI signals from my computer and turn on/off LED lights based on those signals.

Check out the video...




The "MIDI to Arduino Breakout Board" as I call it in the video I designed myself. I used various resources on MIDI around the web and came up with this schematic.




Digikey Part list:


2 x DIN5 - CP-2350-ND
2 x 6N138 - 516-1600-5-ND
1 x diode - 1N914B-ND
2 x 220 ohm resistor
1 x 270 ohm resistor


As you can see it isn't very complicated. The hardest part was finding in DIN5 part numbers at Digikey. The code on the other hand was a bit more complicated. The trick was to decode the MIDI signals without any real debugging tools. The RX/TX ports on the Arduino are being used by the MIDI ports. I had to use blinky LED lights to do the debugging. After fumbling around with it for a while I was able to get it working. The code should easily be expendable to allow for more LED lights. I chose to use the PWM pins on the Arduino so I could adjust the brightness of the LEDs.

I tried to comment the code the best I could. Download it here. Keep in mind that you must disconnect the MIDI breakout board before you program your Arduino or it wont work.


Side Node:

Unfortunately MIDI is meant for instruments and not lights so I wasn't able to really do what I wanted to do. As a future project I would like to implement MIDI show control to allow for more light specific functions. I still have to find a freeware program that supports MIDI show control. I'll keep you posted.

10 comments:

Wayne said...

I've updated the video link to work again and also moved the code to GitHub in case anyone wants to improve it.

EnomYs said...

Hi, works fine but i have a problem. When I play single note from a midi keyboard the LEDS blink in the right way, but when a play a sequence from Logic Pro 9, the LEDS blink random with the same notes I played before on the keyboard. I tried to remove midi filter on Logic but the same... How can I do?
thanks

Wayne said...

Good question. I never had that issue when I had set it up. It could be that logic is sending some sort of MIDI command that isn't recognized by the code and causing some odd behavior. I'd been a while since I've looked at this but you could try to connect to the Arduino via a terminal and modify the code to output all the MIDI commands it is receiving.

StayStayLetGo said...

Is there an updated video link?

Wayne said...

Something must have changed. I have updated the link to the video.

StayStayLetGo said...

Thanks for the quick response. I'm having issues understanding what pins my midi signal in is effecting on the OUT side of things. That is to say, I see the board receiving midi, but my LED isn't firing. Any suggestions?

Wayne said...

In the schematic the RX would be MIDI IN, the TX pin would be MIDI OUT.

In the Demo I used a USB to MIDI converter in which I had the MIDI IN plugged into the port labeled MIDI OUT on the DX7 keyboard. The MIDI OUT from the USB to MIDI converter went into the MIDI IN (RX pin) on my MIDI breakout board. The USB end of course was plugged into my laptop. I used Logic Express to record the MIDI signals from the DX7 and play them back to the arduino through the MIDI breakout board. I suppose I should produce a wiring diagram which would simplify the whole thing.

StayStayLetGo said...

Ahh gotcha. See I had used portions of your code some years ago to just nail down the MIDI IN but it was for a direct action of C3 turning a single LED on. In reality it was just triggering a relay which was effectively "stomping" a guitar pedal. But now I can't figure out which pins I was triggering by looking at the code. Or I'm seeing it an just not understanding what I'm seeing. Whomp Whomp.

For context:
The original project mysteriously vanished when I renovated my house last month so now I'm scrambling to put it back together.

Wayne said...

Wow that's an awesome idea. I never thought of using it to control stomp boxes and the like. Seems like a perfect use case for this. You'll just need to figure out which Arduino PIN you want to use for C3. Based on my code it looks like it might be PIN 11 on the arduino but you can configure that here: https://github.com/prock-fife/midi_led_controller/blob/master/midi_led.pde#L25

The first element in that array should be 'C'.

Wayne said...

Just thinking about some other cool things you could do... you could re-wire your stomp boxes and use digital POTs to control volume/gain/whatever using MIDI. Just throwing an idea out there.. https://www.arduino.cc/en/Tutorial/DigitalPotentiometer

Twittering from the linux command line using curl

Recently I signed up for twitter and have found the need to "twit" from the command line. I found a quick tutorial on how to use ...