Introduction: Quick Arduino MIDI Laser Harp
I've created a few Arduino (and more recently, Olimexino) framed MIDI laser harps (see one here), and I frequently get emails asking for more information on how to build one. I'm putting this instructable together to give a basic introduction to making a framed laser harp with an Arduino. This laser harp is safe, cheap and temporary, and only intended to be a basis for a more complex design. It should only take a couple of hours to build.
To save on costs, this instructable uses darran's MIDI firmware for the 16U2; WARNING! This involves reprogramming the 16U2 chip on the Arduino rev3 using Atmel's Flip software (Linux and Windows only), so it will appear as a MIDI device to your computer. This means you'll need to re-flash the Arduino firmware if you wish to reprogram your Arduino. If you're familiar with this kind of thing, you may wish to use the MocoLUFA library instead.
If you already have some MIDI to USB equipment, you may wish to use the standard, less stressful method of sending MIDI messages described here.
Please be aware, this is my first instructable, and I do not code or do electronics in any professional capacity. If there are any errors, please point them out and I'll make corrections.
Step 1: The Basic Principle
In a framed laser harp, each laser source is paired with a light detector a short distance away. The Arduino continuously monitors the light level at each light detector.
If the light level at a detector drops, we know that the laser beam has been blocked, and we send a MIDI "note on" message to the computer via the USB port (or by another means). If the light level returns, we send a MIDI "note off" message to the computer.
Step 2: Gathering Materials
As mentioned, this is intended to be as quick and cheap as possible, but sourcing materials (if you're not lucky enough to have a drawer full of lasers and photodiodes) can take a little while. You will need:
- 1 x Arduino (rev3) and USB cable
- A reasonably sized piece of breadboard (or 2)
- 6 x Laser modules (more on these below)
- 6 x SFH203 visible light photodiodes (more on these below)
- Single core wire or jumper cables for making connections
- A selection of resistors (which you'll use depends on your lasers and photodiodes - I'm using 6 x 100ohm and 6 x 100Kohm)
- Wire cutters
- Blu-tack (I use this to quickly mount and adjust the laser modules). White-tack has not been tested.
- Some form of MIDI-enabled synthesiser - for most this will be a music program on a PC. There is free software available that can do this, such as MuLab or VSThost.
Laser diodes: A note on safety - For this instructable, you should not use any laser module with an output more powerful than 5mw, and certainly never look directly into any laser. Mine are purchased direct from a Chinese company (dinodirect.com) and are cheap, but take an unnervingly long time to arrive. Many people will find it more reliable, easier, and quicker to buy cheap laser pointers (approx £2/$3) and take out the laser modules.
Photodiodes: I use these from RS.com, but they are available from other sites. I've settled on them after a number of projects. They have a fairly narrow angle of sensitivity, so you'll need to aim them at the light source you're detecting.
Step 3: Wiring the Laser Modules
You'll need to wire your laser modules in parallel, with a current limiting resistor for each module. Your resistor value should be matched to your diode, but 100 ohms should be sufficient. If you're unsure, you can check a suitable value here. Stick each laser module down with a generous blob of blu-tack, aiming them roughly where you expect to have the light detector array. Alternatively you could manufacture a frame that holds them in place.
My laser modules have a fairly short wires, so for the rest of this instructable the laser harp is being built at a pretty funky angle, and has a (very) small playing area. You may wish to scale it up and use two separate breadboards for the lasers and photodiodes.
Step 4: Wiring the Photodiodes
Each photodiode needs a 100K resistor, wired as in the image and schematic above. The photodiodes need to be reverse-biased when connected - put simply, the opposite way round to the way you'd wire an LED.
Step 5: Connect the Power and Turn It On
Now you'll need to run a cable from the 5v and GND pin on the Arduino, and connect it to the 5v and ground rails on the breadboard. Plug in the Arduino briefly to check that everything switches on. If it doesn't, check for bad connections and short-circuits.
If all is good, you can take a moment to align the lasers so each is pointing at it's photodiode partner. It's useful to have a piece of paper while you do this.
Step 6: The Arduino Sketch
Upload the attached sketch (Minimum_Laser_Harp.ino) to your Arduino. Open the serial window and check that you receive messages like "Note On message: note 64, velocity 100" when expected. If you have any stuck notes, or other strange behaviour, check your lasers are aligned and that you're getting analogRead() values that go from 1024 to around 40 when the beam is broken. You can change the threshold variable from 512 to something else if necessary.
When you're getting good consistent note messages, change the midiMode variable to "true" and re-upload to the board. Note: if you're planning to use a 5 pin DIN MIDI connection as described here, simply change the serial rate from 115200 to 31250 and re-upload. You'll now receive a MIDI signal from pin 1 (TX).
Download and install Atmel's flip software and put your Arduino into DFU mode by briefly bridging the reset pin with the ground as described here. Your Arduino will now appear as an "unknown device". Install the DFU drivers for it from Flip's install directory: Atmel\Flip 3.4.7\usb .
Download the Arduino-usbmidi-0.2.hex file from:
Load this .hex file into Flip, and select ATMega16u2 in Flip's "device selection" menu. Open the USB connection (by pressing ctrl-u) and then upload the .hex file to the 16U2 by clicking Run. WARNING - past this point, if you wish to upload new sketches to your Arduino you'll have to reinstate the Arduino-usbserial-atmega16u2-Uno-Rev3.hex file from here.
Step 7: Finished!
Reset the Arduino and it should be automatically recognised as a MIDI device. Now you can open your audio software and test it out. It should behave something like the video.
The scale played is a C major. You can change this by editing the array "scale", commented
in the sketch. Remember you'll have to flash the default Arduino firmware to upload any changes.
I hope this works out for you! Perhaps you feel like putting this into a frame, or adding more lasers & controls, or building it the size of a corridor, or all of the above. Good luck!
3 People Made This Project!
We have a be nice policy.
Please be positive and constructive.