A Simple MIDI synth that manipulates an LED in response to MIDI messages
This is a very simple proof of concept MIDI synth. Listen to MIDI IN and manipulate LEDs in response. I built this to test out MIDI IN circuitry, create the skeleton software to listen and respond to MIDI IN messages, and learn about composing music on my desktop PC and the Mission Control Raspberry Pi.
Before jumping into details, here’s some pics of her in action. You’re not having real fun as a maker unless you’re crafting a light diffuser out of a pizza box and some old expired silicone adhesive.
Source code and schematic available on GitHub in the hcgs-simple-midi-led repository.
This is a prototype, so only lives on a solderless breadboard. With the proof of concept complete, there will be production models to follow in more rugged configurations. The basic circuit for MIDI IN will end up in many Grumpenspiel components. The core structure of the code is easily modified for different behaviors.
The simple pizza box diffuser was a quick and dirty way to get some visual effects. The real fun will come as I make some themed elements for the full entertainment value.
- Arduino Nano controller
- Standard MIDI IN circuit (incl. 6N138 optocoupler) connected to RX pin
- Adafruit NeoPixel output on output pin (just a single thru hole pixel)
- For development and testing:
- three pushbuttons in standard INPUT_PULLUP setup, connected to digital input pins
- three LEDs in standard current limiting resistor setup, connected to digital output pins
- ICSP breakout header to allow firmware upload while MIDI occupies hardware serial
Eagle .sch schematic file is available in the GitHub repository.
The MIDI connector is represented as a 1x2 SIL connector. The close up picture helps me remember the physical connection to the DIN-5 MIDI jack, which will be used in a wide variety of Grumpenspiel projects.
Arduino .ino source code is available in the GitHub repository.
Special thanks go to Parts Not Included for a great write up on how to use the Arduino MIDI library. Real big help!
- Listen to MIDI IN
- Look for NOTE_ON for middle C, E, and G
- C maps to RED
- E maps to GREEN
- G maps to BLUE
- When NOTE_ON received:
- ignore if not a mapped note
- make the color active
- turn on the LED
- turn the color on in the NeoPixel
- When NOTE_OFF received:
- ignore if not a mapped note
- make the color inactive
- turn off the LED
- shut the color down in the NeoPixel
- In loop:
- if a color is active, periodically increment/decrement the intensity
- Additionally listen to three pushbuttons, mapped to notes
- pushbutton pressed same as NOTE_ON
- pushbutton released same as NOTE_OFF
There is a small conflict that I’m definitely going to have to resolve as part of this foray into MIDI love.
MIDI IN needs to read incoming serial data. Two common ways to do that on Arduino:
- PRO : wide variety of pins to choose from
- CON : slow and misses incoming notes if they’re coming fast (picture sliding your hand across a piano keyboard)
- PRO : fast, only loses notes in extreme cases
- CON : no Serial Monitor for debugging, uploading firmware requires disconnecting the MIDI data line from RX
I really want to use HardwareSerial for the note speed issue. During development and testing, prototypes can use SoftwareSerial for simple test note configurations, allowing Serial Monitor access.
The real kick in the butt is the MIDI data line and RX connection. Pain to keep remembering to switch that guy over. Why not try ICSP?
Using a separate Arduino UNO with the ArduinoISP sketch, I was able to upload to the Nano. Nice! With my feebly connected solderless jumper wire setup, happy that the concept was proved, I broke it down and wanted to restore the original bootloader.
Spent the better half of a day going back and forth, burning bootloader with ArduinoISP, also with Nick Gammon’s utility. Just could not get the Nano back to its normal self.
Yeah, eventually figured out that the MIDI data line was hooked to RX that whole time. Unplug, re-fire the bootloader, and golden.
Reinforced the need for a robust and stable setup for repeatable steps and reduced human error.