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

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.

<p>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: https://www.instructables.com/id/Arduino-Laser-Harp-1/</p>
<p>Great work! :)</p>
<p>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.</p><p>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.) </p><p>void setup() {<br>Serial.begin(9600);<br>}<br>void loop() {<br>Serial.println(analogRead(A0));<br>delay(100);<br>}</p><p>Then I followed all the instructions, DFU mode and flip. </p><p>Finally I tried to use MIDI-OX, FL Studio, and MuLab to make the harp sound, but it does not receive any signal.</p><p>I might have done some mistake during the procces but I can't really figure it out.</p><p>Here is also a picture of my project if you want to see it.</p>
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.
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
<p>I got to step 6 and uploaded the sketch. I do not see any messages at all. Any help would be greatly appreciated!</p>
<p>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:</p><p><strong>void setup() {<br>Serial.begin(9600);<br>}<br>void loop() {<br> Serial.println(analogRead(A0));<br> delay(100);<br>}</strong></p><p>Other checks:<br></p><p>Is the midiMode variable in the arduino code set to <strong>false</strong>?</p><p>Is your serial monitor baud rate set to <strong>9600</strong>?</p>
<p>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.</p><p>do you have any other suggestions?</p><p>casey</p>
<p>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.</p>
<p>Hi Benjamin - coupla questions:</p><p>have you set the arduino midiMode to true in the code?</p><p>are you using a software synth or a hardware synth? if hardware, could you share the model?</p>
<p>We are currently using a software synthesizer, we are using midihost but can switch to basically any synthesizer that would work.</p>
<p>I'd suggest using midi-ox for testing, let me know what (if any) messages you receive in that program.</p>
<p>I have the same probrel as Banjamin. I'm using MuLab. Can you please send some pictures how to set up the midi synth?</p>
<p>Hi Miroslav. Are you using native USB midi or a MIDI to USB cable?</p>
<p>hey, friends...</p><p>i made it </p><p>but i want to play notes using MIDI to usb cable..</p><p>i have cable but i dont know how to use it..</p><p>so please give me a full details and code for it please...</p><p>ncp619@gmail.com</p>
<p>oky dear i will try today</p><p>thank you!!</p>
<p>hellow everyone, </p><p>i wanna play more than 6 notes,</p><p>like i wanna assemble 9 laser diode and play diff diff notes..</p><p>but arduino analogue have only 6 pins, </p><p>so what can i do?</p><p>please if possible whole code please </p><p>i have very little time for complete this work..</p><p>help!! </p>
<p>I would suggest using a multiplexer like the CD74HC4067 to increase the number of analog inputs, or: </p><p>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.</p>
<p>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.</p><p>The only part I found is this.</p><p> <a href="http://www.amazon.com/gp/product/B00BVCCA90/ref=gno_cart_title_0?ie=UTF8&psc=1&smid=AODFMOUHD0RRM" rel="nofollow">http://www.amazon.com/gp/product/B00BVCCA90/ref=gn...</a></p>
<p>I saw your website <a href="http://www.foxytronics.com" rel="nofollow">www.foxytronics.com</a> it has good tutorials also. many thanks.</p>
<p>Does somebody have any idea how to control the volume on this instructable?</p><p>For example: use a HC-RS04. Any idea how to do this?</p>
<p>You could tie the MIDI volume to a sensor, something like:</p><p><strong>midiVolume = map(analogRead(A0),0,1023,0,127); //where A0 is the sensor input<br></strong></p><p><strong>midimessage(0x80, 60, midiVolume)</strong></p><p>The above is a rough example and will probably need heavy tweaking.</p><p>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: </p><p><a href="http://chrisballprojects.wordpress.com/2012/05/09/a-little-more-information/" rel="nofollow">http://chrisballprojects.wordpress.com/2012/05/09/...</a></p>
<p>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?</p>
<p>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.</p><p>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.</p><p>On Windows, I've done this in this past by using <a href="https://processing.org/" rel="nofollow">Processing</a> to convert the serial messages to MIDI, then used <a href="https://processing.org/" rel="nofollow">MIDI Yoke</a> (a virtual MIDI in/out) to route them to a DAW or MIDI output.</p>
<p>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 &quot;codes&quot; 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?</p>
<p>You would differentiate between serial messages by making sure they're differentiable from the arduino - you can send whatever you like, e.g. &quot;note On Channel 1 Note 64 Velocity 100&quot; but it doesn't need to be that specific.</p><p>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.</p><p>I'm not sure what you mean by mapping...can you explain more?</p>
<p>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.</p><p>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 &lt; 155) { &quot;play some note&quot; } . However there is constantly a break in the playing of the sound and I cannot understand why?</p><p>Like it plays for say like 0.5s then stops momentarily and then starts again</p>
<p>Send me your code! I'm happy to diagnose it - you can find my contact details on chrisballprojects.wordpress.com</p>
<p>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.</p><p>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.</p>
<p>Hi! Very exciting to hear you've made one - it looks great :)</p><p>Not sure why your photodiodes wouldn't work, but you can usually adjust the sensitivity by changing the value of their accompanying resistor.</p>
<p>Hi, I am new to all of this but was wondering if there is any way to make this work with garage band?</p>
<p>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.</p>
<p>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. </p><p>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</p><blockquote> if(midiMode){<br> Serial.begin(115200); //midi USB baud rate = 115200 for usb<br> }else{<br>Serial.begin(31250); </blockquote><p>A keyboard plugged into the same jack produces notes. It looks like I'm getting note off info but not note on.</p>
<p>If the midiMode variable is set to &quot;true&quot; at the top of the sketch, then the number you need to change is the 115200, i.e.</p><p><strong>boolean midiMode=true;<br><br>void setup(){<br> if(midiMode){<br> Serial.begin(31250); //midi baud rate = 31250<br> }else{<br> Serial.begin(9600); //for testing values<br> }<br>}</strong></p><p>Let me know if that helps :)</p>
<p>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. </p>
<p>Not sure why that would be, but you can try changing the line:</p><p><strong>int beginNote=0x3C; </strong></p><p>(0x3C = 60 in hexadecimal) to:</p><p><strong>int beginNote=0x6C; </strong>or<strong> int beginNote=108; </strong></p><p>(108 = 60 + (4 x 12) - 4 octaves higher) <br></p><p><br></p>

About This Instructable




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