(Above) The Advanced Theremin as I had it set up. I placed the sensors separate to allow each hand to control a tone. (via me)
The last BBC Micro:bit Theremin project had you create a single channel for sound. This, “ADVANCED,” Theremin will up that to two channels. The idea here is to create two different tones at the same time. One high pitched and the other lower.
The software works as follows:
- When the Micro:bit powers up, you set the ambient light level limit by pressing the button “A.”
- Then cover the phototransistor with your hand, press the “B” button. This sets the other limit.
- Now when you place your hand over the phototransistor, the sound the Micro:bit is producing will change. This goes for both channels.
Keep in mind, both channels are playing out of the same speaker. So, it might not be apparent that they are, but the sounds are mixed. More on how to test each channel later in this tutorial.
First, let’s gather all the necessary components you’ll need to build this project.
Project Wires Female - Male
1x Speaker (Powered speaker recommended.)
Video demonstration of the project:
STEP 1
Load the code onto the Micro:bit.
I am providing the hex file you need to drag and drop onto the Micro:bit, and the python code as two separate files. For the below process, just use the hex file.
Plug the MicroUSB cable into the Micro:bit, and plug the other end of the cable to a PC or MAC.
At this point, you are going to copy over the code to the Micro:bit. I am providing the program (code) in this post that needs to be copied over. When the Micro:bit plugs into a computer, it shows up as a USB flash drive. All you have to do is copy the file over to the Micro:bit, like it’s a USB Flash Drive, and the Micro:bit will reset, and the program is active.
You can remove the Micro:bit from the computer at this point. The program will start running, and without the rest of the circuit, it will not function.
A little bit about the code:
The system itself can be fairly quiet. I suggested a powered speaker. However, you can change the volume in the top declarations.
The system is quiet, just like the previous one. I declared a variable “VolumeAtt” at the top. This dictates the volume of the sound. Technically, you can place an integer value from [2…512], but you might want to experiment with it. Depending on the speaker, you may get a louder sound, or you will just pop the speaker’s diaphragm all the way. That would just make the speaker try to play sound outside its ability.
Also, you can turn the screen LEDs on and off here too by changing the “LED_ON” variable from “True” to “False.” However, the LEDs will show what the sensors are “seeing.”
Lines 1-2 show Pin 1’s code and lines 3-4 show Pin 2’s code. The more LEDs lit indicates the saturation. In other words, all on and you will hear the max frequency tone.
I offer the option to turn them off since the light will slightly effect the sound coming out of the system.
The rest of the code is commented fairly well if you want to see what is going on in it.
STEP 2
I used the breakout board for this project. It’s great for testing and setting up where space and reliability isn’t an issue. It also helps to quickly get at the pins on the Micro:bit.
Two small breadboards are definitely recommended for the phototransistor circuit. One for each tone.
Lay the Micro:bit and Kitronik Inventor’s Kit on a table. Insert the edge-card end of the Micro:bit into the Inventor’s Kit socket and stick a breadboard to the bottom part of the Inventor’s Kit.
STEP 3
Wire up the schematic to the breakout board.
STEP 4
Plug USB 5V power to the Micro:bit.
At this point, you will hear a little sound.
- Now, press the “A” button to set the ambient light level limit.
- Cover the phototransistor and press the “B” button to set the other limit.
Note: With the Advanced version, both sensors are set simultaneously. So, be sure to light them equally for pressing “A” and cover at the same time for “B.”
To test individual channels, shine a light onto the one you DO NOT want to hear. This essentially forces that channel into a frequency that is almost an “off” state.
STEP 5
Now you can wave your hand over the phototransistor to change the sound outputted by the Micro:bit.
It might sound kind of crazy combining two frequencies. If you hear too much noise at first, try shining more light on them than you set the ambient level at. This will turn them off, sort of. Then you can try activating with your hands.
Conclusion:
Now you have a two-tone sound generator!