Introduction: Make a Simple Ultrasonic Theremin
This project is an arduino based ultrasonic theremin.
I was thinking about making a theremin for a long time. I found myself drawn to an Arduino based version in which I could experiment with the different libraries and sounds. Initially, I decided to refer to one project I saw online.
It was based on the “Mozzi” library in the Arduino and required a mono audio amplifier for the sound. It also used an accelerometer so that it would create a broken haunted sound when tilted but since I didn’t require that additional feature, I tailored the code and circuit accordingly. However, the amplifier kept giving me trouble with the power supplies despite trying a variety of arrangements. Since I didn’t even require the “haunted vibrato sound” that “Mozzi” had particularly used for, I decided to move on and design a new variation altogether.
Designing the project
I came across the “ToneAC” library which was simple enough to code for and used the “New Ping” library for my ultrasonic signal. While the ToneAC worked perfectly, the newPing one didn’t work well for the range of sound I wanted and also kept giving a constant sound when it went out of range which I didn’t want. I also read that it wasn’t very compatible with the ToneAC library; in any case, I decided to switch to the “Ultrasonic” library to detect the distance and rewrote the whole code since it gave me distance in cm while NewPing gave it in microseconds. I tinkered around with the frequency formula to achieve the desired optimum range(about 120 cm) and pitch(plays about 1.5 octaves) and also changed my circuit. One good thing about both libraries is that the pins are clearly defined and there is no ambiguity regarding default pins. Also the speaker is directly connected to the Arduino so if you use the USB cable, it doesn’t cause any power supply problems and is able to produce a clear and loud sound. However, it doesn't work well with a battery pack which is not able to provide as much current and so upon attaching it, you can actually see the Arduino light up and then dim away.
Additional adjustments and polishing
For the volume control, I attached a potentiometer between the speaker and Arduino so that player could vary it by a knob. Because it worked best using a board, I made a theremin board with finger holds at the back to grasp it properly. Finally, I found a nice casing for the main circuit, drilled a few holes for the speaker wires, the sensor and the USB cable(so I could directly plug in in the Arduino) without taking it out(I put in some wood pieces to ensure the Arduino stays in place). I put all these components-the box case, the speaker and the USB cable and adapter in a compact box so it was like a kit-all you needed to do was plus in the USB cable and attach the adapter to a power outlet and play!
Speaker-16 ohms(you can use a lesser voltage but this one gives the best volume)
Potentiometer- upto 10k
Arduino Uno(with USB cable)
Wires and a casing to put everything in
Code and circuit
Code used for the circuit can be found at: Code
The circuit for this project is very simple. The speaker connects directly to the Arduino with the ground wire going to pin 9 and the positive wire to pin 10 through the potentiometer. For the ultrasonic sensor, trig goes to 12, echo goes to 13, and power and ground go to 5V and ground respectively.
Step 5: Couple of More Videos:
Have fun building!
Participated in the
First Time Author Contest
3 years ago
This looks like a lot of fun :)
You should consider entering this in the First Time Author Contest :)
Reply 3 years ago