Why speaker does not start when I power the arduino?

I want to play a frequency of 432 hz (Hertz) immediately after I power up the arduino.
My circuit diagram:

My code:

void setup() {
  // put your setup code here, to run once:
  pinMode(9, OUTPUT);
  tone(9, 432);
}

void loop() {
  // put your main code here, to run repeatedly:
}

The problem is that the speaker does not start when I power the arduino;
It starts when I press the reset button; I also tried pressing the tone(9,432); function in the void loop() but the output is same;
I want to know how to start the speaker when powered the arduino;
(like using capacitors, etc)

This should give a 500ms tone :thinking:
tone(9, 432, 500);

Show us your wiring.

Normally, the board resets automatically when powered-up so I don't know why that's not happening...

That would re-start the tone() function every time through the loop and you might not get a "smooth" tone.

There are other ways to start/run something once without putting in in setup() but it should be OK the way you are doing it. It looks like the program is not running at all so moving it somewhere else wouldn't help.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.