Introduction: Quick Arduino MIDI Laser Harp

Picture of Quick Arduino MIDI Laser Harp

Hi there!

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

Picture of 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

Picture of 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 ( 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, 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

Picture of 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

Picture of 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

Picture of 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

//major scale

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!


yaroshka made it! (author)2015-08-17

Hi Chris, thank you so much for your wonderful instructable! It helped me a lot in general understanding of how a laser harp works. Here is what I build based on your and other people's projects:

Chris Ball (author)yaroshka2015-08-18

Great work! :)

Amishaj (author)2017-10-03

Hi Chris,how will i download usbmidi-0.2.hex file...the link which u have provided to download the hex file is blank.Please do reply.

Thank you

Chris Ball (author)Amishaj2017-10-03

Oh no! I think you can get a version here;

under "firmwares", "Arduino-usbmidi.hex". Bear in mind this file is untested.

Lukale (author)2016-01-10

Hi Chris, I followed you instructable until the end, my computer recognizes Arduino as a MIDI device, but when it comes to use a MIDI software it does not work. It may be a problem with the board because when I broke a beam, the light in arduino does not blink.

I uploaded the sketch changing the arduino code to true and, even I checked if the wiring is good and if arduino recognised if a beam was broken with the script you'd given in a past comment; and it worked correctly (in the serial window some numbers between 0 and 5 started to run, so I thought it was ok.)

void setup() {
void loop() {

Then I followed all the instructions, DFU mode and flip.

Finally I tried to use MIDI-OX, FL Studio, and MuLab to make the harp sound, but it does not receive any signal.

I might have done some mistake during the procces but I can't really figure it out.

Here is also a picture of my project if you want to see it.

KartikeyaT1 (author)2015-10-06

Hi Chris. Im trying to build the harp,its just that there are so many lasers available I dont know which 1 to buy.Plz Suggest something.

martinb58 (author)2015-09-30

Hi chris, i have an issue with my proyect, the problem is that i don't know how to create de music, in my proyect i code the arduino. I have to use a especific program, all i want is my laser arp make sound. Thanks

CaseyS3 (author)2015-06-02

I got to step 6 and uploaded the sketch. I do not see any messages at all. Any help would be greatly appreciated!

Chris Ball (author)CaseyS32015-06-03

Hi Casey, are you using the same photodiodes (SFH213) as I was? If you're not, you may need to adjust the threshold variable from 512 to something more suitable, and double check your wiring. This simple sketch should help you find a suitable threshold value, and establish whether your wiring is good:

void setup() {
void loop() {

Other checks:

Is the midiMode variable in the arduino code set to false?

Is your serial monitor baud rate set to 9600?

CaseyS3 (author)Chris Ball2015-06-03

I am using the same photodiodes and the midiMode is set to false. I put the baud at 9600. I followed your wiring in the pictures and matched it exactly to yours.

do you have any other suggestions?


BenjaminS4 (author)2015-04-24

Hi me and my friend have been attempting to make this for a project. We currently are having issues making it for the arduino actually plays the notes. We have it for it is set as an arduino-midi and the board seems to be recognizing that we break the beam. However, whenever we do break the beam the note does not play, we have a feeling that the issue is within the midi synthesizer. Could you perhaps send us some photos of how your synthesizer was set up and which one you used.

Chris Ball (author)BenjaminS42015-04-25

Hi Benjamin - coupla questions:

have you set the arduino midiMode to true in the code?

are you using a software synth or a hardware synth? if hardware, could you share the model?

BenjaminS4 (author)Chris Ball2015-04-27

We are currently using a software synthesizer, we are using midihost but can switch to basically any synthesizer that would work.

Chris Ball (author)BenjaminS42015-05-06

I'd suggest using midi-ox for testing, let me know what (if any) messages you receive in that program.

MiroslavH (author)Chris Ball2015-05-11

I have the same probrel as Banjamin. I'm using MuLab. Can you please send some pictures how to set up the midi synth?

Chris Ball (author)MiroslavH2015-05-12

Hi Miroslav. Are you using native USB midi or a MIDI to USB cable?

maleeha.khan.7583 (author)2015-05-01

ncp619 (author)2015-04-04

hey, friends...

i made it

but i want to play notes using MIDI to usb cable..

i have cable but i dont know how to use it..

so please give me a full details and code for it please...

Chris Ball (author)2015-03-25

Hi Matthew,
try changing the threshold value, and also check that you are getting analog input values that make sense.

ncp619 (author)2015-03-21

oky dear i will try today

thank you!!

ncp619 (author)2015-03-20

hellow everyone,

i wanna play more than 6 notes,

like i wanna assemble 9 laser diode and play diff diff notes..

but arduino analogue have only 6 pins,

so what can i do?

please if possible whole code please

i have very little time for complete this work..


Chris Ball (author)ncp6192015-03-21

I would suggest using a multiplexer like the CD74HC4067 to increase the number of analog inputs, or:

adapt the design to work with the arduino's digital pins; by adjusting the photodiode's resistor value until you get the response you need.

lost2010 (author)2015-01-23

I cant seem to find the parts you used on any USA websites. I have never made or done anthing like this. I have never done anything electrical like this before and I am pretty lost. I need to build something that is an interactive form of media for my class and i thought a laser harp would be cool.

The only part I found is this.

goldenshuttle (author)2014-12-31

I saw your website it has good tutorials also. many thanks.

uJonne (author)2014-11-18

Does somebody have any idea how to control the volume on this instructable?

For example: use a HC-RS04. Any idea how to do this?

Chris Ball (author)uJonne2014-11-18

You could tie the MIDI volume to a sensor, something like:

midiVolume = map(analogRead(A0),0,1023,0,127); //where A0 is the sensor input

midimessage(0x80, 60, midiVolume)

The above is a rough example and will probably need heavy tweaking.

You could also map the volume to the time it takes for the detected light to drop to zero - so a fast hand moving into the beam produces a loud note, and a slow hand a quiet note. I explain this in more detail in a blog post here:

eoinclancy1 (author)2014-10-30

Regarding re-flashing the chip, does anyone know if it is safe to do this on an intel galileo? Would the listed software work allright on the galileo?

Chris Ball (author)eoinclancy12014-10-30

I suspect not, but not being overly familiar with the Galileo, I don't know. I would expect that there's a more direct route to MIDI over USB for the Galileo, but a quick search has turned up nothing.

A possible (although lengthy) solution would be to send normal Serial messages over USB, and then convert them to usable MIDI in software at the PC side.

On Windows, I've done this in this past by using Processing to convert the serial messages to MIDI, then used MIDI Yoke (a virtual MIDI in/out) to route them to a DAW or MIDI output.

eoinclancy1 (author)Chris Ball2014-11-02

Thanks so much for your reply. I'm just wondering, because i'm trying to use lrds in my system which the lasers shine on, how do i differentiate between serial "codes" when they come into my laptop, assuming that i'm using 6 lasers. Like how will i be able to find out if one note is playing over another? Would mapping work in arduino for this?

Chris Ball (author)eoinclancy12014-11-07

You would differentiate between serial messages by making sure they're differentiable from the arduino - you can send whatever you like, e.g. "note On Channel 1 Note 64 Velocity 100" but it doesn't need to be that specific.

MIDI messages are instantaneous, not constant; meaning a message is sent only when a note is switched on or off (basically, when something changes). You can tell which notes are playing simultaneously by looking at the note On messages you've recently received.

I'm not sure what you mean by mapping...can you explain more?

eoinclancy1 (author)Chris Ball2014-11-09

mapping actually does what you are saying to do in your first paragraph. it converts the scale of say 1 to 1023 to any scale you want. eg. 0,170 or 0,500. will map the same notes over the new distance.

I have just been trying to use tones in the aduino library to get started by i cannot seem to get a constant sound once a beam is broken. I am currently trying if statements and while loops, but neither is working. My condition in the statements is like if(ldr1value < 155) { "play some note" } . However there is constantly a break in the playing of the sound and I cannot understand why?

Like it plays for say like 0.5s then stops momentarily and then starts again

Chris Ball (author)eoinclancy12014-11-11

Send me your code! I'm happy to diagnose it - you can find my contact details on

Catan97. made it! (author)2014-11-08

I appreciate your work so much... Without this we would never have been able to make it! We also referred much to your blog articles to design and build the frame and control panel.

Just one comment; for some reason the photodiodes we had didn't work. The signal it sent to the arduino hardly varied as the brightly of light shed on it changed. Instead we used CdS cells.

Chris Ball (author)Catan97.2014-11-08

Hi! Very exciting to hear you've made one - it looks great :)

Not sure why your photodiodes wouldn't work, but you can usually adjust the sensitivity by changing the value of their accompanying resistor.

LauraM4 (author)2014-11-07

Hi, I am new to all of this but was wondering if there is any way to make this work with garage band?

Chris Ball (author)LauraM42014-11-07

Hi, if you've followed the instructable correctly, you should be able to use this instrument as a normal MIDI device with garageBand; exactly like a USB keyboard.

webweave made it! (author)2014-02-24

I built mine on a block of wood to be able to move it around without disturbing the alignment and I plan to expand it to more notes.

That's a midi jack in the top of the photo, I think I missed something because its outputting midi info but its not triggering notes. I changed the following line to 31250 from 9600

Serial.begin(115200); //midi USB baud rate = 115200 for usb

A keyboard plugged into the same jack produces notes. It looks like I'm getting note off info but not note on.

Chris Ball (author)webweave2014-02-24

If the midiMode variable is set to "true" at the top of the sketch, then the number you need to change is the 115200, i.e.

boolean midiMode=true;

void setup(){
Serial.begin(31250); //midi baud rate = 31250
Serial.begin(9600); //for testing values

Let me know if that helps :)

webweave (author)Chris Ball2014-02-24

Very cool Chris, thanks. Yes that helps I can see the notes being triggered but now my notes start at 4 octaves below middle c.

Chris Ball (author)webweave2014-02-24

Not sure why that would be, but you can try changing the line:

int beginNote=0x3C;

(0x3C = 60 in hexadecimal) to:

int beginNote=0x6C; or int beginNote=108;

(108 = 60 + (4 x 12) - 4 octaves higher)

About This Instructable




More by Chris Ball:Quick Arduino MIDI Laser Harp
Add instructable to: