Arduino theramin

I'm building a light theremin in Arduino. The only problem is that I have trouble using the serial monitor. Could you guys please help me add it into my code successfully. It works in real life but I also built here in tinkercad.

image
Here is the code for it
int sensorValue;
int sensorLow = 1023;
int sensorHigh = 0;

const int ledPin = 13;

void setup() {

pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);

while (millis() < 1000) {

sensorValue = analogRead(A0);
if (sensorValue > sensorHigh) {
  sensorHigh = sensorValue;
}
if (sensorValue < sensorLow) {
  sensorLow = sensorValue;
}

}

digitalWrite(ledPin, LOW);
}

void loop() {
sensorValue = analogRead(A0);

int pitch =
map(sensorValue,sensorLow,sensorHigh, 50, 4000);
analogWrite (ledPin, map(sensorValue, 50, 255, 0, 100));

tone(8,pitch,20);

delay(10);
}

Please edit and add [code] tags to your post.

A schematic will help us more than a pretty Frizzy drawing.

Thanks

That's to be expected as serial monitor is a feature running and existing in the IDE.
Use Arduino.cc/reference for facts about serial and serial monitor.

What sort of trouble? After adding code tags to your post, explain what you want to do, what you have tried, and what went wrong.

I just want it to be able to monitor the pitch in serial monitor

You can use Serial.print() to display the values of program variables as text. The serial monitor does not have audio input.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.