So I have this bit of code (im using Arduino Uno):
void playerInput() //when player presses button
{
if(digitalRead(ledPin[0]) == HIGH) {
digitalWrite(whiteLed, HIGH);
tone(11,1000,300); //score point tone ERROR - SEEMS TO PLAY LOSING TONE EVEN ON A WIN
delay(30000);
digitalWrite(whiteLed, LOW);
digitalWrite(ledPin[0], LOW);
}
else if (digitalRead(ledPin[0]) == LOW) {
tone(11,250,400); //lose score tone
delay(40000);
}
}
When the player presses their button at the correct time, the white LED should light up and the piezo should play the correct sound (a higher pitch). If they press it at the wrong time it doesnt light up and the incorrect sound plays (lower pitch). However when they press it at the correct time, the white LED DOES light up, but the piezo plays the incorrect sound. Am I missing something with the Tone() function? Please help! If you need to see any more of the code please ask. Thanks in advance.