437Views7Replies

Author Options:

problem with my code Answered

This is the top of the code where i am getting the error. "Tone speakerpin" is the line that it is talking about.
The error says "Tone" does not name a type.
Please help

#include <Tone.h>
Tone speakerpin;
int starttune[] = {NOTE_C4, NOTE_F4, NOTE_C4, NOTE_F4, NOTE_C4, NOTE_F4, NOTE_C4, NOTE_F4, NOTE_G4, NOTE_F4, NOTE_E4, NOTE_F4, NOTE_G4};
int duration2[] = {100, 200, 100, 200, 100, 400, 100, 100, 100, 100, 200, 100, 500};
int note[] = {NOTE_C4, NOTE_C4, NOTE_G4, NOTE_C5, NOTE_G4, NOTE_C5};
int duration[] = {100, 100, 100, 300, 100, 300};
boolean button[] = {2, 3, 4, 5}; //The four button input pins
boolean ledpin[] = {8, 9, 10, 11};  // LED pins
int turn = 0;  // turn counter
int buttonstate = 0;  // button state checker
int randomArray[100]; //Intentionally long to store up to 100 inputs (doubtful anyone will get this far)
int inputArray[100];

7 Replies

user
steveastrouk (author)2012-11-01

Where's the code from ?

What is "Tone", what is "speakerpin" ?

Select as Best AnswerUndo Best Answer

user
font1135 (author)steveastrouk2012-11-02

i think that is my issue as well but i am not very savy with this program basically i just took the code from this site.
https://www.instructables.com/id/Arduino-Simon-Says/?ALLSTEPS

Select as Best AnswerUndo Best Answer

user
steveastrouk (author)font11352012-11-02

Was it in the .zip file ?

Select as Best AnswerUndo Best Answer

user
frollard (author)2012-11-01

It means you don't have the Tone.h library installed in your arduino/libraries folder.

You get that error as if tone isn't there because adding Tone.h will define a type but since its not there the type isn't declared.

I presume this is the library you need
http://code.google.com/p/rogue-code/downloads/detail?name=Arduino-Library-Tone.zip

Select as Best AnswerUndo Best Answer

user
bwrussell (author)frollard2012-11-02

+1, you can include the library in your code all day but it doesn't do any good without actually loading the library into the IDE.

Select as Best AnswerUndo Best Answer

user
steveastrouk (author)frollard2012-11-01

Its got a horribly opaque error message system. Why it can't say "tone.h not ound in path" ?

Select as Best AnswerUndo Best Answer

user
frollard (author)steveastrouk2012-11-02

Agreed;

I bet it does -- He's giving one line of a 15-20 line error.
I recall arduino should give the specific line causing the distress (tone does not name a type) - as well as other info (tone.h not found)

Select as Best AnswerUndo Best Answer