A Sound Generator Using Time-of-Flight Sensors
Build a modern twist on the classic Theremin using time-of-flight sensors and analog sound generation. No musical talent required, just a love for tinkering!
Note: this project will be explained in more detail in the Circuit Special edition this summer. I hope this overview will spark your curiosity! Earlier this year, I explored ST’s VL53L series of time-of-flight (ToF) sensors and was impressed by the multi-zone capabilities of the VL53L8CX. But for this project, I focused on its simpler cousin, the VL53L4CD. The goal here? Try to make a kind of mixed-signal sound generator, a bit like a classic Theremin, but with two of these modern, digital ToF sensors (one for pitch and one for volume) paired with an XR2206 analog signal generator. While everything could be done on an Arduino or ESP32, it wouldn't have been nearly as much fun!
The sensors communicate via I²C. I used a breadboard-friendly breakout board from Adafruit, which includes level shifting and voltage regulation, to help prototyping. The XR2206, though discontinued, is still widely available as clones. A capacitor/resistor pair controls the frequency of its output. I chose to use a PWM output from a microcontroller (which is still mandatory due to the sensors using I²C…) to vary the timing resistance, changing the frequency. Volume is controlled in a similar way via another PWM channel, with another transistor adjusting the XR2206’s output gain.

The Arduino sketch uses STM32duino’s VL53L4CD library, which offers helpful functions like InitSensor(), CheckForDataReady(), etc. The output is delivered via analogWrite() and passed through a simple RC filter to the transistors mentioned before. However, there is still a lot of room for improvement! Due to my very far-from-perfect analog implementation, the PWM duty cycle variation doesn’t fully exploit the range for frequency. Volume control is slightly better, but I’m sure there are better ways to do this and make the “instrument” (should I say contraption?) easier to play. If you come across the article in the summer issue, you can look into it and let me know what you think would be the best option.
This was an intriguing journey in the vast world of distance sensors, if you’re interested I suggest checking out the broader range of products in the ST line, or trying multizone sensors for gesture recognition. What other interesting sensors or components have you used recently? Feel free to share your suggestions in the comments below. Happy tinkering!
Diskussion (0 Kommentare)