-2
/*

*/

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

{

}

closed as unclear what you're asking by jfpoilpret, SDsolar, Enric Blanco, Code Gorilla, gre_gor Jun 5 '17 at 14:50

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • What happens when you run the updated code? – per1234 Jun 3 '17 at 2:16
  • 2
    Why 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
1

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    
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.