issue with my code.

my code

void loop() {
  
  sensorValue = analogRead(A0);
  int pitch = map(sensorValue,sensorHigh, 50, 4000);
  tone(8,pitch,20);
  
  
  
  delay(10);
}

comes up with this error

error: a function-definition is not allowed here before '{' token
void loop() {

what have i dine wrong?

You haven't posted all your code.

rfearnley:
what have i dine wrong?

Not posted the part of the code where the error is..

My guess is a missing "}" prior to "void loop()".

 int sensorValue;
int sensorLow = 1023;
int sensorHigh = 0;
const int ledPin = 13;

void setup() {
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);
  
  while (millis() < 5000) {
    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,sensorHigh, 50, 4000);
  tone(8,pitch,20);
  
  
  
  delay(10);
}

sorry forgot code

Yup, and you forgot setup's closing brace.

thanks it workd :slight_smile: