Pages: [1] 2   Go Down
Author Topic: Trying to use the Tone library, but getting compile errors  (Read 12164 times)
0 Members and 2 Guests are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi folks, I'm trying to use the Tone library (found at http://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation), but I get the following error messages when I try to compile the demos:

Quote
C:\Users\yoshito\arduino-1.0\libraries\Tone\Tone.cpp:26:20: error: wiring.h: No such file or directory
C:\Users\yoshito\arduino-1.0\libraries\Tone\Tone.cpp: In member function 'void Tone::begin(uint8_t)':
C:\Users\yoshito\arduino-1.0\libraries\Tone\Tone.cpp:121: error: 'bitWrite' was not declared in this scope
C:\Users\yoshito\arduino-1.0\libraries\Tone\Tone.cpp:123: error: 'digitalPinToPort' was not declared in this scope
C:\Users\yoshito\arduino-1.0\libraries\Tone\Tone.cpp:123: error: 'portOutputRegister' was not declared in this scope
C:\Users\yoshito\arduino-1.0\libraries\Tone\Tone.cpp:124: error: 'digitalPinToBitMask' was not declared in this scope
C:\Users\yoshito\arduino-1.0\libraries\Tone\Tone.cpp: In member function 'void Tone::play(uint16_t, uint32_t)':
C:\Users\yoshito\arduino-1.0\libraries\Tone\Tone.cpp:198: error: 'OUTPUT' was not declared in this scope
C:\Users\yoshito\arduino-1.0\libraries\Tone\Tone.cpp:198: error: 'pinMode' was not declared in this scope
C:\Users\yoshito\arduino-1.0\libraries\Tone\Tone.cpp:294: error: 'bitWrite' was not declared in this scope
C:\Users\yoshito\arduino-1.0\libraries\Tone\Tone.cpp: In member function 'void Tone::stop()':
C:\Users\yoshito\arduino-1.0\libraries\Tone\Tone.cpp:361: error: 'digitalWrite' was not declared in this scope

I'm pretty new to the entire coding thing, so could anybody help out with suggestions?  Very much obliged!
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 201
Posts: 8662
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That version of the Tone library has not been updated for Arduino 1.0.  Change "wiring.h" to "Arduino.h" to see if that's the only problem.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

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

Quote
Change "wiring.h" to "Arduino.h" to see if that's the only problem.

Doing this resolved all the compile errors.  Thank you very much for your help!
Logged

Hampshire
Offline Offline
Jr. Member
**
Karma: 0
Posts: 77
Have a passion for electronics!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Where can I find wiring.h? Thank you
Logged

TrevorB

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In the 1.0 IDE it's here:

hardware/arduino/cores/arduino/wiring.h
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
In the 1.0 IDE it's here:

hardware/arduino/cores/arduino/wiring.h
Not in an unmodified version of the IDE, it isn't. wiring.h was renamed to wiring_private.h, because code is not supposed to directly include wiring.h.
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You're right, should check and not trust my "locate" output showing me some old version stuff... Thanks.
Logged

Austria
Offline Offline
Full Member
***
Karma: 5
Posts: 100
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

actually i am trying to use this great library to generate some dtmf tones. But in fact i cannot get it working on newer 1.02 (or 1.00) IDE, only on the older 0023  smiley-sad
Can You please advise me how to do? What does modified IDE mean, can i download this or are there any detailed instructions how to do this myselves?

Is there any newer or better library to generate dtmf on 1.02 Arduino?

Christian
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
But in fact i cannot get it working on newer 1.02 (or 1.00) IDE, only on the older 0023
"It doesn't work" is about the lamest statement you can make on this forum.

Far better is to post some code, and some error messages, if relevant, and ask for help understanding them.

Nearly every 0023 to 1.0 conversion issues has been hammered to death here.
Logged

Austria
Offline Offline
Full Member
***
Karma: 5
Posts: 100
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank You for Yout quick response!

Well, this is the code i am trying to use, it is the dtmf example included in the library:
http://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation

// DTMF (Dual Tone Multiple Frequency) Demonstration

// http://en.wikipedia.org/wiki/Dual-tone_multi-frequency

// To mix the output of the signals to output to a small speaker (i.e. 8 Ohms or higher),
// simply use 1K Ohm resistors from each output pin and tie them together at the speaker.
// Don't forget to connect the other side of the speaker to ground!

#include <Tone.h>

Tone freq1;
Tone freq2;

const int DTMF_freq1[] = { 1336, 1209, 1336, 1477, 1209, 1336, 1477, 1209, 1336, 1477 };
const int DTMF_freq2[] = {  941,  697,  697,  697,  770,  770,  770,  852,  852,  852 };

void setup()
{
  Serial.begin(9600);
  freq1.begin(11);
  freq2.begin(12);
}

void playDTMF(uint8_t number, long duration)
{
  freq1.play(DTMF_freq1[number], duration);
  freq2.play(DTMF_freq2[number], duration);
}


void loop()
{
  int i;
  uint8_t phone_number[] = { 8, 6, 7, 5, 3, 0 ,9 };

  for(i = 0; i < sizeof(phone_number); i ++)
  {
    Serial.print(phone_number, 10);
    Serial.print(' ');
    playDTMF(phone_number, 500);
    delay(600);
  }
 
  Serial.println();
  delay(4000);
}


... and i will get the following error messages:

C:\Dokumente und Einstellungen\user\Desktop\arduino-1.0.2\libraries\Tone\Tone.cpp: In member function 'void Tone::begin(uint8_t)':
C:\Dokumente und Einstellungen\user\Desktop\arduino-1.0.2\libraries\Tone\Tone.cpp:121: error: 'bitWrite' was not declared in this scope
C:\Dokumente und Einstellungen\user\Desktop\arduino-1.0.2\libraries\Tone\Tone.cpp:123: error: 'digitalPinToPort' was not declared in this scope
C:\Dokumente und Einstellungen\user\Desktop\arduino-1.0.2\libraries\Tone\Tone.cpp:123: error: 'portOutputRegister' was not declared in this scope
C:\Dokumente und Einstellungen\user\Desktop\arduino-1.0.2\libraries\Tone\Tone.cpp:124: error: 'digitalPinToBitMask' was not declared in this scope
C:\Dokumente und Einstellungen\user\Desktop\arduino-1.0.2\libraries\Tone\Tone.cpp: In member function 'void Tone::play(uint16_t, uint32_t)':
C:\Dokumente und Einstellungen\user\Desktop\arduino-1.0.2\libraries\Tone\Tone.cpp:198: error: 'OUTPUT' was not declared in this scope
C:\Dokumente und Einstellungen\user\Desktop\arduino-1.0.2\libraries\Tone\Tone.cpp:198: error: 'pinMode' was not declared in this scope
C:\Dokumente und Einstellungen\user\Desktop\arduino-1.0.2\libraries\Tone\Tone.cpp:294: error: 'bitWrite' was not declared in this scope
C:\Dokumente und Einstellungen\user\Desktop\arduino-1.0.2\libraries\Tone\Tone.cpp: In member function 'void Tone::stop()':
C:\Dokumente und Einstellungen\user\Desktop\arduino-1.0.2\libraries\Tone\Tone.cpp:361: error: 'digitalWrite' was not declared in this scope


My problem is that i am arduino beginner andhfor me it is still very difficult to find the right help for this problem ...
« Last Edit: December 09, 2012, 12:12:21 pm by elektron_ » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Apparently, you didn't read about how to install libraries. The Arduino core library folder is NOT where user downloaded libraries go.

One of the decisions that the Arduino team made was that if the preprocessor can not find a library, for 1.0.1 or later, that is OK. Bullshit. It is not.

Compiling on 1.0.0:
Quote
C:\Users\pjs9486\Documents\Arduino\libraries\Tone\Tone.cpp:26:20: error: wiring.h: No such file or directory
C:\Users\pjs9486\Documents\Arduino\libraries\Tone\Tone.cpp: In member function 'void Tone::begin(uint8_t)':
C:\Users\pjs9486\Documents\Arduino\libraries\Tone\Tone.cpp:121: error: 'bitWrite' was not declared in this scope
C:\Users\pjs9486\Documents\Arduino\libraries\Tone\Tone.cpp:123: error: 'digitalPinToPort' was not declared in this scope
C:\Users\pjs9486\Documents\Arduino\libraries\Tone\Tone.cpp:123: error: 'portOutputRegister' was not declared in this scope
C:\Users\pjs9486\Documents\Arduino\libraries\Tone\Tone.cpp:124: error: 'digitalPinToBitMask' was not declared in this scope
C:\Users\pjs9486\Documents\Arduino\libraries\Tone\Tone.cpp: In member function 'void Tone::play(uint16_t, uint32_t)':
C:\Users\pjs9486\Documents\Arduino\libraries\Tone\Tone.cpp:198: error: 'OUTPUT' was not declared in this scope
C:\Users\pjs9486\Documents\Arduino\libraries\Tone\Tone.cpp:198: error: 'pinMode' was not declared in this scope
C:\Users\pjs9486\Documents\Arduino\libraries\Tone\Tone.cpp:294: error: 'bitWrite' was not declared in this scope
C:\Users\pjs9486\Documents\Arduino\libraries\Tone\Tone.cpp: In member function 'void Tone::stop()':
C:\Users\pjs9486\Documents\Arduino\libraries\Tone\Tone.cpp:361: error: 'digitalWrite' was not declared in this scope

Now, a quick search for the first error message says to change wiring.h to Arduino.h, since the library is NOT being used on a wiring board.

Strangely enough, doing that results in a new set of error messages. Resolving these is left for you to do:
Quote
Binary sketch size: 4606 bytes (of a 30720 byte maximum)
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 201
Posts: 8662
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In Desktop\arduino-1.0.2\libraries\Tone\Tone.cpp change
Code:
#include <wprogram.h>
to
Code:
#include <Arduino.h>
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
In Desktop\arduino-1.0.2\libraries\Tone\Tone.cpp
Tone.cpp does not use WProgram.h. It uses wiring.h (and pins_arduino.h, that it shouldn't). It is wiring.h that needs to be changed to Arduino.h (and the include of pins_arduino.h deleted).
Logged

Austria
Offline Offline
Full Member
***
Karma: 5
Posts: 100
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

...it is running now. It is realy only the tone.cpp which needs the little modification  smiley

Thank You.

Chris

Logged

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

Hi all,

excuse my english hi  smiley

i'm using the Tone library with Arduino v1.03. i modifiy the .cpp & the exemple run correctly but ...

i' trying to  use in my program & i have this compilation errors :

have some idea ?

thanks a lot

Patrick

the compilation error :

core.a(Tone.cpp.o): In function `__vector_7':
D:\App\arduino-1.0.3\hardware\arduino\cores\arduino/Tone.cpp:535: multiple definition of `__vector_7'
Tone\Tone.cpp.o:D:\App\arduino-1.0.3\libraries\Tone/Tone.cpp:439: first defined here
core.a(Tone.cpp.o): In function `disableTimer(unsigned char)':
D:\App\arduino-1.0.3\hardware\arduino\cores\arduino/Tone.cpp:426: multiple definition of `timer2_toggle_count'
Tone\Tone.cpp.o:D:\App\arduino-1.0.3\libraries\Tone/Tone.cpp:102: first defined here
core.a(Tone.cpp.o): In function `disableTimer(unsigned char)':
D:\App\arduino-1.0.3\hardware\arduino\cores\arduino/Tone.cpp:426: multiple definition of `timer2_pin_port'
Tone\Tone.cpp.o:D:\App\arduino-1.0.3\libraries\Tone/Tone.cpp:102: first defined here
core.a(Tone.cpp.o): In function `disableTimer(unsigned char)':
D:\App\arduino-1.0.3\hardware\arduino\cores\arduino/Tone.cpp:426: multiple definition of `timer2_pin_mask'
Tone\Tone.cpp.o:D:\App\arduino-1.0.3\libraries\Tone/Tone.cpp:102: first defined here
core.a(Tone.cpp.o): In function `disableTimer(unsigned char)':
D:\App\arduino-1.0.3\hardware\arduino\cores\arduino/Tone.cpp:426: multiple definition of `timer0_pin_port'
Tone\Tone.cpp.o:D:\App\arduino-1.0.3\libraries\Tone/Tone.cpp:102: first defined here
core.a(Tone.cpp.o): In function `disableTimer(unsigned char)':
D:\App\arduino-1.0.3\hardware\arduino\cores\arduino/Tone.cpp:426: multiple definition of `timer0_pin_mask'
Tone\Tone.cpp.o:D:\App\arduino-1.0.3\libraries\Tone/Tone.cpp:102: first defined here
core.a(Tone.cpp.o): In function `disableTimer(unsigned char)':
D:\App\arduino-1.0.3\hardware\arduino\cores\arduino/Tone.cpp:426: multiple definition of `timer1_pin_port'
Tone\Tone.cpp.o:D:\App\arduino-1.0.3\libraries\Tone/Tone.cpp:102: first defined here
core.a(Tone.cpp.o): In function `disableTimer(unsigned char)':
D:\App\arduino-1.0.3\hardware\arduino\cores\arduino/Tone.cpp:426: multiple definition of `timer1_pin_mask'
Tone\Tone.cpp.o:D:\App\arduino-1.0.3\libraries\Tone/Tone.cpp:102: first defined here
core.a(Tone.cpp.o): In function `disableTimer(unsigned char)':
D:\App\arduino-1.0.3\hardware\arduino\cores\arduino/Tone.cpp:426: multiple definition of `timer0_toggle_count'
Tone\Tone.cpp.o:D:\App\arduino-1.0.3\libraries\Tone/Tone.cpp:102: first defined here
core.a(Tone.cpp.o): In function `disableTimer(unsigned char)':
D:\App\arduino-1.0.3\hardware\arduino\cores\arduino/Tone.cpp:426: multiple definition of `timer1_toggle_count'
Tone\Tone.cpp.o:D:\App\arduino-1.0.3\libraries\Tone/Tone.cpp:102: first defined here
Logged

Pages: [1] 2   Go Up
Jump to: