Hello!
I am trying to control the sound of a Theremin with a photoresistor (Project 06 in the Arduino project book.)
The problem is: The Theremin does not change it sound at all, so i must have done a mistake in the code.
I appreciate if someone could give me any advice ![]()
int sensorValue;
int sensorLow = 1023;
int sensorHigh = 0;
const int ledPin = 13;
void setup() {
//Turn on LED pin to indicate calibration has started
pinMode (ledPin,OUTPUT);
digitalWrite (ledPin, HIGH);
while (millis() < 5000) {
//Set sensor high
 sensorValue = analogRead(A0);
 if (sensorValue > sensorHigh); {
  sensorHigh=sensorValue;
}
//Set sensor low
 if (sensorValue < sensorLow); {
  sensorLow=sensorValue;
}Â
 }
//Turn off LED to indicate calibration is complete
digitalWrite(ledPin, LOW);
}
void loop() {
//Read the sensor value
sensorValue = analogRead (A0);
int pitch =
 map (sensorValue,sensorLow,sensorHigh, 50, 4000);
tone (8,pitch,20);
//Delay to give sound time to play
delay (50);
Â
}
I am happy for any feedback ![]()
Thank You!