Youâve built blinking LEDs. Youâve built a robot that immediately drove itself off the table. Now, itâs time to build an instrument you donât even have to touch to play. Because who wants to learn actual guitar chords when you can aggressively wave your hands through frickinâ laser beams like a discount Jean-Michel Jarre? If youâve ever wanted to accidentally blind yourself while playing âMary Had a Little Lamb,â this is the project for you.
(Standard disclaimer: Please donât actually blind yourself. Do not look directly into the lasers).
The core concept here is deceptively simple. We are going to aim a bank of cheap 5V laser modules directly at a row of photoresistors (LDRs). As long as the laser is hitting the LDR, the resistance is low. When you wave your hand through the beam, you block the light, the resistance spikes, and the Arduino registers that a âstringâ has been plucked. It then triggers a soundâin our case, a simple tone out of a piezo buzzer, but you could easily expand this to send MIDI signals to your computer!

This project requires a physical structure. You need a rigid frame (wood, PVC, or 3D printed) to hold the lasers on top and the LDRs on the bottom, perfectly aligned.
Drill 6 holes in the top bar for your laser modules, and 6 matching holes directly below them in the bottom bar for the LDRs. Space them about 2 inches apartâenough room for your clumsy fingers to break one beam without hitting the adjacent ones.
Each LDR needs to be wired as a voltage divider.
When the laser hits the LDR, the analog pin will read a high value (close to 1023). When your hand breaks the beam, it will drop significantly.
Here is the basic code to get your laser harp singing. We define a threshold valueâif the analog reading drops below this number, the beam is broken and we play a tone.
const int numStrings = 6;
// Analog pins for the LDRs
const int ldrPins[numStrings] = {A0, A1, A2, A3, A4, A5};
// Frequencies for the notes (C4, D4, E4, F4, G4, A4)
const int notes[numStrings] = {261, 294, 329, 349, 392, 440};
const int buzzerPin = 8;
const int threshold = 500; // Adjust this based on your ambient room light!
void setup() {
Serial.begin(9600);
pinMode(buzzerPin, OUTPUT);
}
void loop() {
bool stringPlucked = false;
for (int i = 0; i < numStrings; i++) {
int sensorValue = analogRead(ldrPins[i]);
// If the reading drops below our threshold, the beam is broken
if (sensorValue < threshold) {
tone(buzzerPin, notes[i]); // Play the note
stringPlucked = true;
break; // Only play one note at a time for this basic version
}
}
// If no beams are broken, stop the buzzer
if (!stringPlucked) {
noTone(buzzerPin);
}
delay(10); // Small delay for stability
}
Depending on how bright your room is, and exactly how directly the laser hits your LDR, you will likely need to adjust the threshold variable. Use Serial.println(sensorValue) to see what values your Arduino reads when the beam is unbroken vs. broken, and set the threshold right in the middle!
A piezo buzzer sounds terrible. Itâs great for proof of concept, but itâs not music. The next logical step for this project is to swap the tone() commands for standard MIDI Serial.write() commands, run a MIDI-to-Serial bridge on your PC, and use your laser harp to trigger massive, sweeping synth pads in a DAW like Ableton or Logic Pro. Check out our DIY Arduino MIDI Controller guide for a primer on how to get started with MIDI!