E textiles & wearables II

Theme : Sound and electronics

Idea : create an instrument, Theremin.

The Theremin is an electronic instrument creating sound with no physical contact.

there is easier way to make sound with a sensor light and a piezo.

I follow this tutorial from John Nussey to start.

tools used :

  • Arduino uno
  • Breadboard
  • Piezo buzzer
  • Light sensor
  • 2 resistors 0.22
  • jump wires
step 1 :

schema :

The light sensor is connected to analog 0 on one side and 5V on the other.

the 2 resistors are connected between analog 0 and ground.


Circuit :


I did the Circuit with two resistors of 0.22 to have more or less the equivalent of a 4.7K resistor.


First, to understand the circuit and to know if a sound was going to be produce by the piezo, I connected everything on a breadboard.

I tried first with this piezo :



The sensor was capting different intensity of light and was producing sound from the piezo :

I tried with a Piezo buzzer instead. The sound is louder and has a different tonality depending on the code.

you can find the link HERE.


I tried with another code from the tutorial of Massimo Banzi and the sound has a different tonality.

cf HERE.


to be able to integrate this circuit into a fabric, I was thinking to use a ATtiny85 but unfortunately the Arduino “Tone” function is not supported on the ATtiny85 because it doesn't have the appropriate timers. I therefore needed to find a replacement way of generating simple tones.


Code :

LED pin
const int ledPin= 13;
int sensorValue;
int sensorHigh;
int sensorLow; void setup() {
put your setup code here, to run once:
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);

calibrate during the first five seconds
while (millis() < 5000) {
sensorValue = analogRead(A0);
record the maximum sensor value
if (sensorValue > sensorHigh) {
sensorHigh = sensorValue;

record the minilum sensor value
if (sensorValue < sensorLow) {
sensorLow = sensorValue;

signal the end of the calibration period
digitalWrite(ledPin, LOW);


void loop() {
read the input from A0
sensorValue = analogRead(A0);
map the sensor values to a wide range of pitches
adjust the values bellow to conform the maximum and minimum
numbers you get from your sensor
int pitch =map(sensorValue, sensorLow,sensorHigh, 50, 4000);

play the tone
wait for a moment