Go Down

Topic: Error in running Tone tutorial (Read 3755 times) previous topic - next topic

Agusta

i tried running the tutorial posted here(http://arduino.cc/en/Tutorial/tone)
but i have been getting the following errors after compilation-->

core.a(main.cpp.o): In function `main':
undefined reference to `setup'

undefined reference to `loop'

can i get help ?

dxw00d


Agusta

uhh, im using the arduino IDE  :smiley-roll:

dxw00d

#3
Mar 24, 2012, 02:30 pm Last Edit: Mar 24, 2012, 02:43 pm by dxw00d Reason: 1
Just checking. Can you post the code you are trying to compile. The code listed on the tutorial page compiles fine.

Agusta

#4
Mar 24, 2012, 03:06 pm Last Edit: Mar 30, 2012, 09:56 am by Coding Badly Reason: 1
this is the code:
Code: [Select]
#define NOTE_G3  196
#define NOTE_B3  247
#define NOTE_A3  220
#define NOTE_C4  262
int melody[] = {
 NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4};

int noteDurations[] = {
 4, 8, 8, 4,4,4,4,4 };

void setup() {
 for (int thisNote = 0; thisNote < 8; thisNote++) {
   int noteDuration = 1000/noteDurations[thisNote];
   tone(8, melody[thisNote],noteDuration);
   int pauseBetweenNotes = noteDuration * 1.30;
   delay(pauseBetweenNotes);
   noTone(8);
 }
}

void loop() {
}

---------------------xxxxxx---------------------
ERROR:

core.a(main.cpp.o): In function `main':
F:\Arduino and Processing\arduino-1.0\hardware\arduino\cores\arduino/main.cpp:11: undefined reference to `setup'
F:\Arduino and Processing\arduino-1.0\hardware\arduino\cores\arduino/main.cpp:14: undefined reference to `loop'

Please tell me what am i doing wrong.
Thanks.

dxw00d

I don't know. I just compiled your code (which should be wrapped in [code]...[/code] tags) without any trouble. I would guess there is something wrong with your installation. Can you compile any of the example sketches?

Agusta

Yes i have been able to successfully run many sketches, dont know whats going wrong with this one

dxw00d

I think I'd try wiping and reinstalling the IDE.

bethlena

there's something up with this code or something. i'm having the same problem with the Tone tutorial. i've been working with the arduino for a couple of months, and this is the first time i've seen this error. i wiped the IDE from my computer and redownloaded the same version, and i got the same error.
for what it's worth, i'm on a PC using windows 7.
if anybody can look into this and figure it out, that would be super great. i was really looking forward to using this tutorial to play different tunes.

Coding Badly


Are you using Agusta's code or the code from the tutorial?

dxw00d

I have successfully compiled both the original Tutorial code, and Agusta's.

bethlena

i'm using the code from the tutorial. i've seen this issue - with the Tone tutorial - posted on other forums, and people trying to help have also been unable to replicate the problem. it's weird.
are you on a mac or PC?

dxw00d

#12
Mar 30, 2012, 06:25 pm Last Edit: Mar 30, 2012, 06:30 pm by dxw00d Reason: 1
I'm on a Mac. My Windows box is in use at the moment. I'll try it on there later.

Coding Badly

i'm using the code from the tutorial.


Are you using the "Get Code" link?

bethlena

yes, i had clicked on "Get Code" and copied and pasted the entire code.

Go Up