Āé¶¹“«Ć½

How to make a theremin with a light sensor

Hannah Joshua shows how to make a theremin with an easy microbit program and light sensor
David Stock for Āé¶¹“«Ć½/Thanks to ICL Advanced Hackspace

Ģż

New stuff you need
If you have the parts for previous projects, you will have everything required.

NOW that our circuits are getting smart, it is easy to think that just using a micro:bit microcontroller is as good as it gets. But while it does have an impressive range of components, we can augment it with extras.

The micro:bit’s gold strip is where the magic happens. It is split into 25 bands, called pins, which are connection points to the internal electronics. Extra components are usually linked to one of these, along with the part in the corner marked ā€œGNDā€, or ground, making a circuit through the micro:bit. The device directs the electricity flowing through the pins to control your addition.

Take your piezo buzzer, and use a couple of crocodile clips to attach it to the micro:bit’s 0 pin and ground. Go to the ā€œMusicā€ menu in the online micro:bit editor and find ā€œring tone (Hz) Middle Cā€. Clip that into the ā€œforeverā€ block in the workspace, so it plays continuously, and upload the program to your device. Unplug it from the computer and attach the 3-volt battery. This way, it will be easier to hide the noisy gadget in a housemate’s room.

Just kidding. We are actually going to use the micro:bit’s light sensor to make a – a musical instrument that you play without touching. Sensors take an input from the environment and convert it into electrical impulses. The micro:bit’s light sensor is made of a material that changes electrical resistance according to the light level. This adjusts the current flowing through it. We can use the output of the light sensor to pick a note for the buzzer to play.

Trouble is, the readings on the light sensor go from 0 (total darkness) to 255 (full brightness). We want to shift this range to correspond to note frequencies.

In the code editor, start a new project and create a variable called ā€œnoteā€. Grab ā€œset note to 0ā€ and clip it into ā€œforeverā€. Using ā€œmapā€¦ā€ from the ā€œMathā€ menu and ā€œlight levelā€ from ā€œInputā€, we can write a line that says ā€œset note to map light level from low 0 high 255 to low X high Yā€, where X and Y are the frequencies of the lowest and highest notes you want your theremin to play. Mine goes from 262 hertz (around middle C) to 523 hertz (an octave above). Try those numbers as your X and Y. Beneath this block, add another ā€œring tone (Hz) Middle Cā€, but change the default ā€œMiddle Cā€ to your variable, ā€œnoteā€.

Once you have onto the micro:bit, you can play your theremin by moving your hand to block out more or less light, or by shining a torch towards it. You could also reverse the scale or add more octaves.

You could even try a different sensor. For instance, a sonar sensor allows you to use distance rather than light. Let us know what you come up with.

To download a printable version of this page click here

Thanks to Imperial College Advanced Hackspace for use of their facilities

Ģż


For next week

Continuous rotation servo (The 6-volt kind is fine, see website for details)

Sound sensor

Disco ball

Ģż

Next in the series

1 Introduction

2 Electric candle

3 Toast notifier

4 Desktop traffic light

5 Propeller car

6 Magic 8 Ball

7 Theremin

8 Sound-sensitive disco ball:ĢżIt rotates when the music starts

9 Rubbish sweeper

10 Biscuit bot

Projects so far and a full list of kit required are at
Email:Ģżmaker@newscientist.com

Article amended on 18 June 2019

We corrected which pins of the micro:bit circuit board the piezo buzzer should be connected to

Topics: Electronics