Projects / Light theremin

Light theremin

Two LDRs control pitch and note rate as you move your hands over them, like a theremin played with shadows.

Beginner45 minGuided buildReviewed

Build it step by step

0 of 6 done
  1. UNO410 lux

    Wire the sensors

    Build the two LDR dividers and read them on A0 and A1.

  2. UNO

    Print the readings

    Add Serial prints temporarily to see the range for light and shadow.

  3. UNO

    Calibrate

    Reset and wave your hands over both sensors for four seconds.

  4. UNO

    Play

    Move one hand to change pitch and the other to change how often notes sound.

  5. UNO

    Smooth it

    Change the 0.8 and 0.2 values until the notes stop jittering.

  6. UNO

    Mark the sensors

    Stick labels on them so players know which does pitch and which does speed.

In short

How do you build a light theremin?

Two LDRs control pitch and note rate as you move your hands over them, like a theremin played with shadows. You need Arduino Uno R3, LDR Photoresistor × 2, Resistor 10 kΩ × 2, Passive buzzer, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 6 steps and about 45 minutes.

Level
Beginner
Time
About 45 min
Parts
6

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
5VLDR 1 and LDR 2, one leg eachTop of the dividers
LDR 1 other legUno A0 and 10 kΩ resistor to GNDPitch input
LDR 2 other legUno A1 and 10 kΩ resistor to GNDNote-rate input
Uno D8Passive buzzer +Sound
Passive buzzer -Uno GNDReturn

Code

Arduino IDE, board "Arduino Uno". No libraries needed. Keep room light steady while you play. For a smoother tone try a small speaker through a 100 Ω resistor in place of the buzzer.

Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

const byte PITCH = A0, RATE = A1, BUZZER = 8;
int pLo = 1023, pHi = 0, rLo = 1023, rHi = 0;
float pSmooth = 0, rSmooth = 0;

void calibrate() {
  unsigned long t = millis();
  while (millis() - t < 4000) {            // wave your hands over both sensors for 4 seconds
    int p = analogRead(PITCH), r = analogRead(RATE);
    pLo = min(pLo, p); pHi = max(pHi, p);
    rLo = min(rLo, r); rHi = max(rHi, r);
    delay(5);
  }
}

void setup() {
  pinMode(BUZZER, OUTPUT);
  calibrate();
}

void loop() {
  int p = analogRead(PITCH), r = analogRead(RATE);
  pSmooth = 0.8 * pSmooth + 0.2 * p;       // smooth to stop jitter
  rSmooth = 0.8 * rSmooth + 0.2 * r;
  int freq = map((int)pSmooth, pLo, pHi, 200, 1200);
  int gap = map((int)rSmooth, rLo, rHi, 400, 20);   // lower gap means notes more often
  freq = constrain(freq, 100, 2000);
  gap = constrain(gap, 20, 400);
  tone(BUZZER, freq, 60);
  delay(gap + 60);
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Hand over pitch sensorPitch falls or rises smoothly
Hand over rate sensorNotes come faster or slower
Both uncoveredSteady high notes
No movementSteady repeating note

If it does not work

No sound

A passive buzzer needs tone(). Check D8 and the wiring.

Always the same note

Calibration failed. Reset and wave over both sensors.

Notes jitter

Increase the smoothing weight or shade the sensors from other lights.

Pitch backwards

Swap the min and max in the map or swap the LDR and resistor positions.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the light theremin?

Arduino Uno R3, LDR Photoresistor × 2, Resistor 10 kΩ × 2, Passive buzzer, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).

How long does the light theremin take to build?

About 45 minutes for a beginner maker, in 6 steps.

How do I know the light theremin works?

Hand over pitch sensor: Pitch falls or rises smoothly. Hand over rate sensor: Notes come faster or slower. Both uncovered: Steady high notes.

No sound: what should I check?

A passive buzzer needs tone(). Check D8 and the wiring.

Always the same note: what should I check?

Calibration failed. Reset and wave over both sensors.

Notes jitter: what should I check?

Increase the smoothing weight or shade the sensors from other lights.

Pitch backwards: what should I check?

Swap the min and max in the map or swap the LDR and resistor positions.