A theremin is an electronic musical instrument controlled without physical contact by the thereminist (performer). It was patented by Leon Theremin in 1928. The instrument's controlling section usually consists of two metal antennas that sense the relative position of the thereminist's hands and control oscillators for frequency with one hand, and amplitude (volume) with the other [Wikipedia]. You might have already heard to theremin’s music in 1950's SciFi movies or the Beach Boys' song Good Vibrations.
About this projectIn this project we are going to sort of emulate a theremin using Arduino. Most of arduino theremin tutorials use only one sensor, usualy a photosensor, few of them an ultrasonic sensor. In this one we want to use two ultrasonic sensors so we can control both frequency and amplitude, which is closer to how the original works. We will use thetwo sensors to detect distances that will be used in a function to translate them to tone and volume.
Generic ultrasonic sensors have four pins:
- Voltage input.
- Voltage ground.
- Trigger: Sends an ultrasonic pulse through a digital write on the program.
- Echo: Receives the ultrasonic pulse when it bounces back.
The time it takes the pulse from being sent to get back to the board is read and stored in a variable. We will convert this data to distance units (cm).
To control the amplitude we use the NewPing library and the sonar.ping_cm function which sends a ping, returning the distance in centimeters or 0 (zero) if no ping echo within the set distance limit. This information is stored in the variable “distance”. The distance limit is set to 35 (cm) but you can change this based on what you feel is better for you.
Tone (frequency)To convert each distance to a different frequency we are using the NewTone library. We're using the equal temperament system to calculate 12 musical notes. We store this distance in the variable “distance2”, that is used to calculate a range of about 50-360 Hz dividing it by 12. In summary, for every different value of distance we have a different frequency musical note. Sort of.
Sound (output)A regular loudspeaker is connected directly to the output pins of the digital potentiometer. The different values of resistance will be perceived as volume variations. You might want to use an amplifier but is not really necessary.
Comments