Theremin is an analog musical instrument, designed to be played without physical contact. The instrument is played by the thereminist’s movement of hands close to two antennas. In fact, the term antenna is quite misleading, as the rods act as one plate of a capacitor. By moving the hands closer to the antenna, the player can change the pitch and the volume of the instrument.
For this week’s project, I will construct a very simple pitch antenna based on a Hall effect sensor. Compared to other projects, I have chosen this one to be a bit simpler, because the last two took more time than I expected.
The circuit is quite simple. I used a piezo buzzer connected to the D3 port of Arduino Nano. I am reading the analog output from the KY-024 Hall effect sensor and then playing a tone proportional to the digital value. Below, you can see the code for the project:
int analogPin = A0;
int analogVal;
int digitalPin = 3;
void setup() {
// put your setup code here, to run once:
pinMode(analogPin, INPUT);
pinMode(digitalPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
analogVal = analogRead(analogPin);
if (analogVal > 500){
tone(digitalPin, analogVal*2);
}
else{
tone(digitalPin, 0);
}
Serial.println(analogVal);
delay(100);
}