error: class tone has no member named sto

i got a code from the forum to play songs on my piezo, but i tried to upload it, and it gave multiple errors, i fixed all of them, except one. this is the error i get:

Arduino: 1.6.3 (Windows 7), Board:“Arduino Uno”

songs_piezo.ino: In function ‘void play_rtttl(char*)’:

songs_piezo.ino:181:12: error: ‘class Tone’ has no member named ‘sto’

Fout bij compileren.

Can anyone help me?

songs_piezo.ino (8.93 KB)

tone1.sto;

Is that supposed to be 'stop'?

#include <Tone.h>
Tone tone1;
#define OCTAVE_OFFSET 0
int notes[] = { 0,
NOTE_C4, NOTE_CS4, NOTE_D4, NOTE_DS4, NOTE_E4, NOTE_F4, NOTE_FS4, NOTE_G4, NOTE_GS4, NOTE_A4, NOTE_AS4, NOTE_B4,
NOTE_C5, NOTE_CS5, NOTE_D5, NOTE_DS5, NOTE_E5, NOTE_F5, NOTE_FS5, NOTE_G5, NOTE_GS5, NOTE_A5, NOTE_AS5, NOTE_B5,
NOTE_C6, NOTE_CS6, NOTE_D6, NOTE_DS6, NOTE_E6, NOTE_F6, NOTE_FS6, NOTE_G6, NOTE_GS6, NOTE_A6, NOTE_AS6, NOTE_B6,
NOTE_C7, NOTE_CS7, NOTE_D7, NOTE_DS7, NOTE_E7, NOTE_F7, NOTE_FS7, NOTE_G7, NOTE_GS7, NOTE_A7, NOTE_AS7, NOTE_B7
};
char *song = "MissionImp:d=16,o=6,b=95:32d,32d#,32d,32d#,32d,32d#,32d,32d#,32d,32d,32d#,32e,32f,32f#,32g,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,a#,g,2d,32p,a#,g,2c#,32p,a#,g,2c,a#5,8c,2p,32p,a#5,g5,2f#,32p,a#5,g5,2f,32p,a#5,g5,2e,d#,8d";
void setup(void)
{
 Serial.begin(9600);
 tone1.begin(13);
}
#define isdigit(n) (n >= '0' && n <= '9')
void play_rtttl(char *p)
{
 // Absolutely no error checking in here
 byte default_dur = 4;
 byte default_oct = 6;
 int bpm = 63;
 int num;
 long wholenote;
 long duration;
 byte note;
 byte scale;
 // format: d=N,o=N,b=NNN:
 // find the start (skip name, etc)
 while(*p != ':') p++;    // ignore name
 p++;                     // skip ':'
 // get default duration
 if(*p == 'd')
 {
   p++; p++;              // skip "d="
   num = 0;
   while(isdigit(*p))
   {
     num = (num * 10) + (*p++ - '0');
   }
   if(num > 0) default_dur = num;
   p++;                   // skip comma
 }

 Serial.print("ddur: "); Serial.println(default_dur, 10);
 // get default octave
 if(*p == 'o')
 {
   p++; p++;              // skip "o="
   num = *p++ - '0';
   if(num >= 3 && num <=7) default_oct = num;
   p++;                   // skip comma
 }
 Serial.print("doct: "); Serial.println(default_oct, 10);
 // get BPM
 if(*p == 'b')
 {
   p++; p++;              // skip "b="
   num = 0;
   while(isdigit(*p))
   {
     num = (num * 10) + (*p++ - '0');
   }
   bpm = num;
   p++;                   // skip colon
 }
 Serial.print("bpm: "); Serial.println(bpm, 10);
 // BPM usually expresses the number of quarter notes per minute
 wholenote = (60 * 1000L / bpm) * 4;  // this is the time for whole note (in milliseconds)
 Serial.print("wn: "); Serial.println(wholenote, 10);


 // now begin note loop
 while(*p)
 {
   // first, get note duration, if available
   num = 0;
   while(isdigit(*p))
   {
     num = (num * 10) + (*p++ - '0');
   }
   
   if(num) duration = wholenote / num;
   else duration = wholenote / default_dur;  // we will need to check if we are a dotted note after

   // now get the note
   note = 0;

   switch(*p)
   {
     case 'c':
       note = 1;
       break;
     case 'd':
       note = 3;
       break;
     case 'e':
       note = 5;
       break;
     case 'f':
       note = 6;
       break;
     case 'g':
       note = 8;
       break;
     case 'a':
       note = 10;
       break;
     case 'b':
       note = 12;
       break;
     case 'p':
     default:
       note = 0;
   }
   p++;

   // now, get optional '#' sharp
   if(*p == '#')
   {
     note++;
     p++;
   }

   // now, get optional '.' dotted note
   if(*p == '.')
   {
     duration += duration/2;
     p++;
   }
 
   // now, get scale
   if(isdigit(*p))
   {
     scale = *p - '0';
     p++;
   }
   else
   {
     scale = default_oct;
   }
   scale += OCTAVE_OFFSET;
   if(*p == ',')
     p++;       // skip comma for next note (or we may be at the end)

   // now play the note
   if(note)
   {
     Serial.print("Playing: ");
     Serial.print(scale, 10); Serial.print(' ');
     Serial.print(note, 10); Serial.print(" (");
     Serial.print(notes[(scale - 4) * 12 + note], 10);
     Serial.print(") ");
     Serial.println(duration, 10);
     tone1.play(notes[(scale - 4) * 12 + note]);
     delay(duration);
     tone1.sto;
   }
 }
}

if i change it to stop, the error becomes different:

songs_piezo.ino: In function 'void play_rtttl(char*)':

songs_piezo.ino:181:16: error: statement cannot resolve address of overloaded function

Fout bij compileren.

That usually means you put "stop" instead of "stop()"

@AWOL I changed that and again i get errors.Arduino:

C:\Users\lars\AppData\Local\Temp\build8864420021377813993.tmp/core.a(main.cpp.o): In function `main':

C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:43: undefined reference to `loop'

collect2.exe: error: ld returned 1 exit status

Fout bij compileren.

fixed! thanks for the help! :grinning: