I have a code where if i press a button it will beep once then wait for 5 seconds to beep again. But when I upload and press the button only the 1st button beeps the second one makes a small static sound. i have tried adding a delay then noTone then delay again but same results
Im using an arduino uno
here is said code
boolean buttonState1; // boolean variable takes only 1 byte
const byte buttonPin1=10; // byte constant takes only 1 byte
const byte buzz = 13; // named variable allows easy changes later
void setup() {
pinMode(buzz, OUTPUT);
pinMode(buttonPin1, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
buttonState1 = !digitalRead(buttonPin1);
if (buttonState1){ // since they are booleans, you don't need "== HIGH"
tone(buzz,1500,500);
delay(5000);
tone(buzz,1000,500);
}
else {
noTone(buzz);
}
}
this is how the board looks like, im not using digital just a visualization