Introduction: Simple Arduino Laserharp

Here I will describe a way to make a simple Arduino laserharp, a musical instrument that plays music when you block a beam of laser light from hitting a phototransistor. This project was done as a part of the PHYC 308L class at the University of New Mexico, and my detailed notes outlining my process can be found on my Open Science Notebook.

The final product is pictured above.

Step 1: Parts

The parts that you will need for this project are:

Arduino Uno                                                                   $34.99 from Radioshack
Breadboard                                                                    $8.99 from Radioshack
Laserpointer                                                                   $6.99 from Amazon
Diffraction Grating                                                         $8.00 from Amazon
Speaker                                                                          $3.59 from Radioshack
100  resistor
4.7 k resistors (3x)
NTE3034 Phototransistor Detector (3x)                  about $2.50 each
Some cardboard and tape

Step 2: Circuit Assembly

Assembled the circuit as shown below by connecting it to the Arduino.

Step 3: Construction

Next, carefully align the laser with the diffraction grating and the phototransistors. To do this, cut pieces of cardboard to lift the laser pointer to the appropriate level, and tape the diffraction grating to one side. Then adjust its location, and the locations of the phototransistors until the beam strikes each of the phototransistors. At this point, I tape everything into place on the table so that it would not be easily knocked around. The final set up is pictured above.

Step 4: Code

The code that you want to upload to the Arduino is:

const int analogPin0 = A0;
const int analogPin1 = A1;
const int analogPin2 = A2;
const int speaker = 8;
const int threshold = 100;
const int threshold2 = 1;

#include "pitches.h"

void setup() {
  pinMode(speaker, OUTPUT);

void loop() {
  int analogValue0 = analogRead(analogPin0);
  int analogValue1 = analogRead(analogPin1);
  int analogValue2 = analogRead(analogPin2);

  if (analogValue0 < threshold2) {
for (int thisNote = 0; thisNote < 8; thisNote++) {
  else {
  if (analogValue1 < threshold) {
for (int thisNote = 0; thisNote < 8; thisNote++) {

  if (analogValue2 < threshold2) {
for (int thisNote = 0; thisNote < 8; thisNote++) {

This code requires the pitches.h handel that you can find on Arduino's website.

There are two thresholds to make up for the differences in the intensities of the zero and first order diffraction peaks. The lower threshold is for the sensors that detect the first order diffraction peaks that have a much lower intensity.

If you want to change the code so that the speaker plays the note when you shine the laser light on the phototransistor, all you have to do is simply change the inequalities in the if statements so that the analog values are greater than the thresholds.