/*
*/
void setup() // Built in initialization block
{
Serial.begin(9600);
Serial.println("Beep!");
tone(4, 3000, 1000); // Play tone for 1 second
delay(1000); // Delay to finish tone
}
void loop() // Main loop auto-repeats
{
}
-
What happens when you run the updated code? – per1234 Jun 3 '17 at 2:16
-
2Why have you edited your answer, to change the code, that you originally submitted, to the solution that I provided? You have, effectively, changed your question. Are you now saying that the code still does not work? You have also removed all code formatting. – Greenonline Jun 3 '17 at 4:20
-
same thing happens, it does not make any sound – chris19233 Jun 3 '17 at 19:14
-
In that case, you need to ask a different question, which you already have done, here: My Arduino Uno buzzer isn't working. This question, now that it has been reverted to its original meaning, has already been answered. I will vote to reopen your second question, which has (now it appears) been incorrectly closed as a duplicate. Please, in future, do not significantly modify the meaning of your questions, as it moves the goalposts and it previous answers incorrect. Thanks. – Greenonline Jun 3 '17 at 23:38
Because your code, or the relevant part of it, is in setup()
and not in loop()
. Therefore it will only run once, when setup()
is executed, whilst loop()
does nothing, thereafter.
The code should be:
/*
*/
void setup() // Built in initialization block
{
Serial.begin(9600);
Serial.println("Beep!");
}
void loop() // Main loop auto-repeats
{
// Serial.println("Beep!"); // Uncomment this line, if you want your console full of "Beep!" messages
tone(4, 3000, 1000); // Play tone for 1 second
delay(1000); // Delay to finish tone
}