int sensorPin0= A0;
int speakerPin = 3;
int sensorValue0 = 0;
void loop () {
sensorValue0 = analogRead (sensorPin0);
do
{
tone (3, 261)
} While (sensorValue0 <300);
}
There is no error, but the buzzer doesn't play note when sensor is less than 300
There is no setup() function so there is no way that your code will compile with the Arduino IDE and you are missing a semicolon after the tone statement and the while is capitalized. Without setup() there is no pinMode(speakerPin, OUTPUT) so the buzzer wouldn't work, anyway.
Try this. It may not do what you want but it does compile.
int sensorPin0= A0;
int speakerPin = 3;
int sensorValue0 = 0;
void setup()
{
pinMode(speakerPin, OUTPUT);
}
void loop ()
{
sensorValue0 = analogRead (sensorPin0);
do
{
tone (3, 261);
}
while (sensorValue0 <300);
}