Why do i get : 'sensorValue' was not declared in this scope. ?


i bought a microfon and try to test it, i found this test code but the code shows an error but i dont get it so i hope somebody can help me with it.

The Code:

int sensorPin = A5; // select the input pin for the potentiometer
void setup ()
Serial.begin (9600);
void loop ()
sensorValue = analogRead (sensorPin);
delay (500);
Serial.println (sensorValue, DEC);

The error:

Arduino: 1.8.5 (Windows Store (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users+++\Desktop\test\test.ino: In function 'void loop()':

test:8: error: 'sensorValue' was not declared in this scope

sensorValue = analogRead (sensorPin);


exit status 1
'sensorValue' was not declared in this scope

Because you have not told the compiler what type sensorValue is. You need to put the type e.g. int or byte etc. in front of it the first time it is mentioned. Change your line to:

int sensorValue = analogRead (sensorPin);


thx this worked :wink: