Loop with tone

Hi All - just getting started with Arduino. I was hoping the for loop would finish after nine but the sound keeps going. Not sure how to stop it :cold_sweat:

void setup()  { 
    pinMode(9, OUTPUT); // declare pin 9 to be an output:
 void loop() {
   for (int x=0; x<10; x++) {
    tone (9,2); //pin number and frequency
    delay (130); // time tone is on
    noTone (9); // tone off
    delay (130); // time tone is off

Yep, loop() is called over and over again forever.


If you want it to run only once, move the code from loop into setup, under the code already there.

Thanks Wildbill :D