Go Down

Topic: Problemas na compliação (Read 1 time) previous topic - next topic

Luigi_xp

Ola,sou novo aqui

estou tendo um problema na compliação, esta dando um erro: tone1 was not declared in this scope e secleciona Tone tone1; é para tocar o tema do mario no alto falante

Code: [Select]
Tone tone1;

void setup()
{
  tone1.begin(11);//Playback on Pin 11, change to whatever you may need
}

void loop()
{
tone1.play(660,100);
delay(75);tone1.play(660,100);
delay(150);tone1.play(660,100);
delay(150);tone1.play(510,100);
delay(50);tone1.play(660,100);
delay(150);tone1.play(770,100);
delay(275);tone1.play(380,100);
delay(287);tone1.play(510,100);
delay(225);tone1.play(380,100);
delay(200);tone1.play(320,100);
delay(250);tone1.play(440,100);
delay(150);tone1.play(480,80);
delay(165);tone1.play(450,100);
delay(75);tone1.play(430,100);
delay(150);tone1.play(380,100);
delay(100);tone1.play(660,80);
delay(100);tone1.play(760,50);
delay(75);tone1.play(860,100);
delay(150);tone1.play(700,80);
delay(75);tone1.play(760,50);
delay(175);tone1.play(660,80);
delay(150);tone1.play(520,80);
delay(75);tone1.play(580,80);
delay(75);tone1.play(480,80);
delay(175);tone1.play(510,100);
delay(275);tone1.play(380,100);
delay(200);tone1.play(320,100);
delay(250);tone1.play(440,100);
delay(150);tone1.play(480,80);
delay(165);tone1.play(450,100);
delay(75);tone1.play(430,100);
delay(150);tone1.play(380,100);
delay(100);tone1.play(660,80);
delay(100);tone1.play(760,50);
delay(75);tone1.play(860,100);
delay(150);tone1.play(700,80);
delay(75);tone1.play(760,50);
delay(175);tone1.play(660,80);
delay(150);tone1.play(520,80);
delay(75);tone1.play(580,80);
delay(75);tone1.play(480,80);
delay(250);tone1.play(500,100);
delay(150);tone1.play(760,100);
delay(50);tone1.play(720,100);
delay(75);tone1.play(680,100);
delay(75);tone1.play(620,150);
delay(150);tone1.play(650,150);
delay(150);tone1.play(380,100);
delay(75);tone1.play(430,100);
delay(75);tone1.play(500,100);
delay(150);tone1.play(430,100);
delay(75);tone1.play(500,100);
delay(50);tone1.play(570,100);
delay(110);tone1.play(500,100);
delay(150);tone1.play(760,100);
delay(50);tone1.play(720,100);
delay(75);tone1.play(680,100);
delay(75);tone1.play(620,150);
delay(150);tone1.play(650,200);
delay(150);tone1.play(1020,80);
delay(150);tone1.play(1020,80);
delay(75);tone1.play(1020,80);
delay(150);tone1.play(380,100);
delay(150);tone1.play(500,100);
delay(150);tone1.play(760,100);
delay(50);tone1.play(720,100);
delay(75);tone1.play(680,100);
delay(75);tone1.play(620,150);
delay(150);tone1.play(650,150);
delay(150);tone1.play(380,100);
delay(75);tone1.play(430,100);
delay(75);tone1.play(500,100);
delay(150);tone1.play(430,100);
delay(75);tone1.play(500,100);
delay(50);tone1.play(570,100);
delay(110);tone1.play(500,100);
delay(150);tone1.play(760,100);
delay(50);tone1.play(720,100);
delay(75);tone1.play(680,100);
delay(75);tone1.play(620,150);
delay(150);tone1.play(650,200);
delay(150);tone1.play(1020,80);
delay(150);tone1.play(1020,80);
delay(75);tone1.play(1020,80);
delay(150);tone1.play(380,100);
delay(150);tone1.play(500,100);
delay(150);tone1.play(760,100);
delay(50);tone1.play(720,100);
delay(75);tone1.play(680,100);
delay(75);tone1.play(620,150);
delay(150);tone1.play(650,150);
delay(150);tone1.play(380,100);
delay(75);tone1.play(430,100);
delay(75);tone1.play(500,100);
delay(150);tone1.play(430,100);
delay(75);tone1.play(500,100);
delay(50);tone1.play(570,100);
delay(210);tone1.play(585,100);
delay(275);tone1.play(550,100);
delay(210);tone1.play(500,100);
delay(180);tone1.play(380,100);
delay(150);tone1.play(500,100);
delay(150);tone1.play(500,100);
delay(75);tone1.play(500,100);
delay(150);tone1.play(500,60);
delay(75);tone1.play(500,80);
delay(150);tone1.play(500,60);
delay(175);tone1.play(500,80);
delay(75);tone1.play(580,80);
delay(175);tone1.play(660,80);
delay(75);tone1.play(500,80);
delay(150);tone1.play(430,80);
delay(75);tone1.play(380,80);
delay(300);tone1.play(500,60);
delay(75);tone1.play(500,80);
delay(150);tone1.play(500,60);
delay(175);tone1.play(500,80);
delay(75);tone1.play(580,80);
delay(75);tone1.play(660,80);
delay(225);tone1.play(870,80);
delay(162);tone1.play(760,80);
delay(300);tone1.play(500,60);
delay(75);tone1.play(500,80);
delay(150);tone1.play(500,60);
delay(175);tone1.play(500,80);
delay(75);tone1.play(580,80);
delay(175);tone1.play(660,80);
delay(75);tone1.play(500,80);
delay(150);tone1.play(430,80);
delay(75);tone1.play(380,80);
delay(300);tone1.play(660,100);
delay(75);tone1.play(660,100);
delay(150);tone1.play(660,100);
delay(150);tone1.play(510,100);
delay(50);tone1.play(660,100);
delay(150);tone1.play(770,100);
delay(225);tone1.play(380,100);
//tells the user it is over and delays it a little before going to the top again
delay(1000);
tone1.play(440,200);
delay(200);
delay(200);
tone1.play(440,400);
delay(200);
delay(200);
delay(5000);
}


bubulindo

fizeste include da libraria onde está definido o tipo Tone?

This... is a hobby.

Radames

a novas versões da IDE do Arduino já incluem no core uma implementação da função Tone
veja em
http://arduino.cc/en/Reference/Tone
sendo assim vc não precisa incluir nenhuma lib no entanto vc precisa inicializar corretamente as instâncias do tipo Tone.

Luigi_xp

Ok, resolvido. foi só incluir o tone.h

Go Up