Quick Arduino MIDI Laser Harp

52,644

90

32

Intro: 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

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:

http://hunt.net.nz/users/darran/weblog/52882/Arduino_UNO_MIDI_USB_version_02.html

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!

3 People Made This Project!

Recommendations

  • Furniture Contest 2018

    Furniture Contest 2018
  • Tiny Home Contest

    Tiny Home Contest
  • Fix It! Contest

    Fix It! Contest

32 Discussions

0
None
Amishaj

11 months ago

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

1 reply
0
None
Chris BallAmishaj

Reply 11 months ago

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

https://github.com/harlequin-tech/arduino-usb

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

0
None
Lukale

2 years ago

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() {
Serial.begin(9600);
}
void loop() {
Serial.println(analogRead(A0));
delay(100);
}

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.

20160110_121324.jpg
0
None
KartikeyaT1

2 years ago

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.

0
None
martinb58

2 years ago

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

0
None
CaseyS3

3 years ago on Introduction

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

2 replies
0
None
Chris BallCaseyS3

Reply 3 years ago on Introduction

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() {
Serial.begin(9600);
}
void loop() {
Serial.println(analogRead(A0));
delay(100);
}

Other checks:

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

Is your serial monitor baud rate set to 9600?

0
None
CaseyS3Chris Ball

Reply 3 years ago on Introduction

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?

casey

0
None
BenjaminS4

3 years ago on Introduction

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.

5 replies
0
None
Chris BallBenjaminS4

Reply 3 years ago on Introduction

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?

0
None
BenjaminS4Chris Ball

Reply 3 years ago on Introduction

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

0
None
Chris BallBenjaminS4

Reply 3 years ago on Introduction

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

0
None
MiroslavHChris Ball

Reply 3 years ago on Introduction

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

0
None
ncp619

3 years ago on Introduction

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...

ncp619@gmail.com

0
None
Chris Ball

3 years ago on Introduction

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

0
None
ncp619

3 years ago on Introduction

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..

help!!

1 reply
0
None
Chris Ballncp619

Reply 3 years ago on Introduction

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.