Physics of the Theremin: Analog Read-speaker
The Analog Read-speaker project is an incredible introduction to dynamic, real-time hardware manipulation. Instead of writing a song in an array and just letting it play statically, the programmer literally turns an Analog Potentiometer knob to violently force the Arduino tone() function to rapidly accelerate and decelerate its frequency output, mimicking the chaotic sci-fi howling of a vintage electronic Theremin!

The Real-Time Map() Array Execution
If you just run tone(8, analogRead(A0));, the project technically works, but it sounds absolutely terrible!
analogRead(A0)pushes an integer from0 to 1023.- This means the speaker will play frequencies from
0.0Hz(Pure clicking static) up to1023Hz(A high-pitched beep). - The C++ code must forcefully manipulate these bounds utilizing the brilliant
<map()>function! - The Synthesizer Re-Mapping:
int sensorReading = analogRead(A0);
// Compress the 1023 integer output and artificially stretch it across a massive 120Hz to 2500Hz Audio spectrum!
int pitch = map(sensorReading, 0, 1023, 120, 2500);
tone(8, pitch, 10); // Blast the frequency for exactly 10 milliseconds constantly!
- By placing this inside an uninterrupted
loop(), spinning the physical knob slides the massive square-wave generator mathematically up and down an entire 8-octave piano range smoothly!
LDR (Light Dependent Resistor) Substitution Upgrade
To truly build a Science Fiction instrument, rip out the standard Potentiometer.
- Use a standard LDR Photoresistor wired as a voltage divider (using a 10K external resistor).
- Map the ambient light reading! As you physically wave your hand over the photo-resistor, the shadow drops the incoming photon array!
- The Arduino translates the darkness into a collapsing
<map()>structure, causing the pitch of the screeching Piezo buzzer to violently dive-bomb without touching any physical hardware—a flawless Optical Theremin!
Analog Audio Generation Build
- Arduino Uno/Nano (Standard execution speeds are perfectly sufficient).
- 10K Ohm Analog Potentiometer or an LDR (Light Dependent Resistor Photo-Cell).
- Passive Piezoelectric Buzzer (Must be PASSIVE. Doing this with an active buzzer will immediately break the internal oscillator and emit garbage static).
- A 100 Ohm Resistor inserted strictly in series with the buzzer pin to protect the Uno logic gate from massive current back-draw.