PyRaspBeta

← All practice problems

Raspberry Pi practice problem · Projects

Theremin

MediumBudget $10Python · gpiozero

Play music without touching anything: a distance sensor (TRIG GPIO23, ECHO GPIO24, 5 V, ECHO divided down) and a passive buzzer on GPIO18 through a 220 Ω resistor.

  • Hand closer than 60 cm: play 1200 − 10 × distance (cm) hertz (20 cm → 1000 Hz, 50 cm → 700 Hz).
  • Nothing within 60 cm: silence.

Update the note at least 10 times a second. The test hand is away (100 cm), at 20 cm from 1.5 s, at 50 cm from 3.5 s, and gone again at 5.5 s.

Tip: TonalBuzzer(18, octaves=3) reaches 55–3520 Hz; play(Tone(frequency=hz)).

More in Projects