tone library stops playing

hi all

i’m making a couple of robots that as part of their behaviours ‘appear’ to be communicating now and again by sending a few notes at each other from built in speakers. i’m starting a few test sketches using the tonelibrary but have found something i don’t understand.

here’s the code snippet

#include <Tone.h>

Tone tone1;

void setup()
{
tone1.begin(13);
tone1.play(139,600);
delay(700);
tone1.begin(13);
tone1.play(250,400);
delay(500);
tone1.begin(13);
tone1.play(739,300);
delay(700);
tone1.begin(13);
tone1.play(450,500);
delay(550);
tone1.begin(13);
tone1.play(166,300);
delay(500);
tone1.begin(13);
tone1.play(490,700);
}

void loop()
{

i would expect to get 6 notes then silence, but i only get three. i.e the thing stops playing after the third note.

any ideas why?

You need "tone.begin(13)" as a one time initializer (to associate a pin with the library), but there should be no need to call it more than once. Try to remove the call to begin from your sketch (except the first) and see if it helps.

simple but effective. thanks!