0% found this document useful (0 votes)
36 views3 pages

Project 6

This project involves building a light theremin circuit and code. The circuit uses a photoresistor to detect light levels and a piezo buzzer to produce tones. The code calibrates to the minimum and maximum light levels detected, then maps the light readings to pitches between 50-4000Hz played on the buzzer. It reads the photoresistor, maps it to a pitch, plays a 20ms tone, and repeats in a loop.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views3 pages

Project 6

This project involves building a light theremin circuit and code. The circuit uses a photoresistor to detect light levels and a piezo buzzer to produce tones. The code calibrates to the minimum and maximum light levels detected, then maps the light readings to pitches between 50-4000Hz played on the buzzer. It reads the photoresistor, maps it to a pitch, plays a 20ms tone, and repeats in a loop.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Project 6

Assignment:01
1.Light Theremin.

 Circuit 1 (Light Theremin):

 Code:
int sensorValue;
// variable to calibrate low value
int sensorLow = 1023;
// variable to calibrate high value
int sensorHigh = 0;
// LED pin

0
const int ledPin = 13;
void setup() {
// Make the LED pin an output and turn it on
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);
// calibrate for the first five seconds after program runs
while (millis() < 5000) {
// save the maximum sensor value
sensorValue = analogRead(A0);
if (sensorValue > sensorHigh) {
sensorHigh = sensorValue;
}
// save the minimum sensor value
if (sensorValue < sensorLow) {
sensorLow = sensorValue;
}
}
//turn the LED off, signaling the end of the calibration
digitalWrite(ledPin, LOW);
}
void loop() {
//read the input from A0 and store it in a variable
sensorValue=analogRead(A0);
// map the sensor values to a wide range of pitches
int pitch=map(sensorValue, sensorLow, sensorHigh, 50, 4000);
// play the tone for 20 ms on pin 8

1
tone(8, pitch, 20);
// wait for 10ms
delay(10);
}

 Summary
In this project we will make a “Light Theremin” which will work
producing a tone depending on the light perceived by the
microcontroller .
We will need a photoresistor (to detect the quantity of light), a piezo
(buzzer) and a 10kΩ resistor to perform our homemade theremin.
First of all, we will start describing the functionality of a buzzer. This
element is used to ring different tones depending on the intensity
received. It must be connected between ground and a digital or
analogical output which will provide the potential difference needed to
play sounds.
The buzzer will be connected as a digital output and the photoresistor
as an analog input. The photoresistor must be plugged in as an analog
input because it will translate the light received to numbers (different
than the states high/low).

You might also like