Pages: [1] 2   Go Down
Author Topic: Error in running Tone tutorial  (Read 2565 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 19
Posts: 3114
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How are you compiling it?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

uhh, im using the arduino IDE  smiley-roll
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 19
Posts: 3114
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just checking. Can you post the code you are trying to compile. The code listed on the tutorial page compiles fine.
« Last Edit: March 24, 2012, 08:43:47 am by dxw00d » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

this is the code:
Code:
#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.
« Last Edit: March 30, 2012, 02:56:31 am by Coding Badly » Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 19
Posts: 3114
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 19
Posts: 3114
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 19
Posts: 3114
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 19
Posts: 3114
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm on a Mac. My Windows box is in use at the moment. I'll try it on there later.
« Last Edit: March 30, 2012, 11:30:47 am by dxw00d » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

i'm using the code from the tutorial.

Are you using the "Get Code" link?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1] 2   Go Up
Jump to: