heres my code
/*
* Created by ArduinoGetStarted.com
*
* This example code is in the public domain
*
* Tutorial page: https://arduinogetstarted.com/tutorials/arduino-button-piezo-buzzer
*/
const int BUTTON_PIN = 7; // Arduino pin connected to button's pin
const int buzzer= 3; // Arduino pin connected to Buzzer's pin
void setup() {
Serial.begin(9600); // initialize serial
pinMode(BUTTON_PIN, INPUT_PULLUP); // set arduino pin to input pull-up mode
pinMode(buzzer, OUTPUT); // set arduino pin to output mode
}
void loop() {
int buttonState = digitalRead(BUTTON_PIN); // read new state
if (buttonState == HIGH) {
Serial.println("The button is being pressed");
tone(buzzer, 1000);
}
else
if (buttonState == LOW) {
Serial.println("The button is unpressed");
noTone(buzzer);
}
Serial.println("after the sound");
}
Serial.println("after the sound"); This code is never executed. How do I clear the timer on compare? What compare thanks/