Pages: [1]   Go Down
Author Topic: Compiling error  (Read 490 times)
0 Members and 1 Guest are viewing this topic.
Portugal, Rio Tinto
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello.

I'm making an DTMF encoder with an arduino uno r3, soft v1.0.3, but I'm having some problems compiling this code.

every thing I'm using, including libraries, can be found in this file:
OldPhone - My arduino code
Tone - Library
www.ruicaldas.com/downloads/OldPhone.zip

Can anyone point me in the right direction?

Thanks in advanced!

the error messages:
OldTelephone.cpp.o: In function `playDTMF(unsigned char, long)':
C:\Program Files (x86)\arduino-1.0.3/OldTelephone.ino:38: undefined reference to `Tone::play(unsigned int, unsigned long)'
C:\Program Files (x86)\arduino-1.0.3/OldTelephone.ino:39: undefined reference to `Tone::play(unsigned int, unsigned long)'
OldTelephone.cpp.o: In function `setup':
C:\Program Files (x86)\arduino-1.0.3/OldTelephone.ino:31: undefined reference to `Tone::begin(unsigned char)'
C:\Program Files (x86)\arduino-1.0.3/OldTelephone.ino:33: undefined reference to `Tone::begin(unsigned char)'

the code:
Code:
#include <Tone.h>
Tone COL;
Tone ROW;
const int DTMF_COL[] = { 1336, 1209, 1336, 1477, 1209, 1336, 1477, 1209, 1336, 1477 };
const int DTMF_ROW[] = {  941,  697,  697,  697,  770,  770,  770,  852,  852,  852 };

const int colTonepin = 6;
const int rowTonepin = 7;
const int dialingPin = 4;
const int pulsePin = 2;
const int ledPin = 13;

int buttonPushCounter = 0;
int pulseCounter = 0;
int dialingPinState = 0;
int pulsePinState = 0;
int lastdialingPinState = 1;
int lastpulsePinState = 0;
int number = 0;

void setup() {
  pinMode(colTonepin, OUTPUT);
  pinMode(rowTonepin, OUTPUT);
  pinMode(dialingPin, INPUT);
  pinMode(pulsePin, INPUT);
  pinMode(ledPin, OUTPUT);
 
  COL.begin(6);
  ROW.begin(7);

  Serial.begin(9600);
}

void playDTMF(uint8_t number, long duration) {
  COL.play(DTMF_COL[number], duration);
  ROW.play(DTMF_ROW[number], duration);
}

void loop() {
  delay(5);
  dialingPinState = digitalRead(dialingPin);
  pulsePinState = digitalRead(pulsePin);

  if (dialingPinState != lastdialingPinState) {
      if (dialingPinState == HIGH) {
        Serial.println("dialing ON");       
      }
      else {
        if (number == 0) {
          Serial.println("NO INPUT");
        }
        if (number == 1) {
          Serial.println(number);
          playDTMF(1, 500);
        }
        if (number == 2) {
          Serial.println(number);
        }
        if (number == 3) {
          Serial.println(number);
        }
        if (number == 4) {
          Serial.println(number);
        }
        if (number == 5) {
          Serial.println(number);
        }
        if (number == 6) {
          Serial.println(number);
        }
        if (number == 7) {
          Serial.println(number);
        }
        if (number == 8) {
          Serial.println(number);
        }
        if (number == 9) {
          Serial.println(number);
        }
        if (number == 10) {
          Serial.println("0");
        }
        Serial.println("dialing OFF");
        number = 0;
      }
  }
  if (dialingPinState == HIGH) {
    if (pulsePinState != lastpulsePinState) {
          if (pulsePinState == HIGH) {
            number++;
          }
        }
  }
  // save the current state as the last state,
  //for next time through the loop
  lastpulsePinState = pulsePinState;
  lastdialingPinState = dialingPinState;
}

Logged

Portugal, Rio Tinto
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry!
Found an error.
Pin 6 and 7 in use... changed to 11 12 but the problem maintains!

Code:
  COL.begin(11);
  ROW.begin(12);
Logged

Offline Offline
Edison Member
*
Karma: 56
Posts: 2156
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just a note; consider using Switch instead of if if if if
http://arduino.cc/en/Reference/SwitchCase
switch (var) {
    case 1:
      //do something when var equals 1
      break;
    case 2:
      //do something when var equals 2
      break;
     etc...   
Logged

Offline Offline
Sr. Member
****
Karma: 9
Posts: 254
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Where did you get the Tone.h file from, I've got the same Tone.cpp, from the Arduino core library, however it doesn't match the Tone.h that you've got, they have completely different functions in them, Tone.h declares a class Tone, which you have been trying to use in your code, but the Tone.cpp files seems to contain a bunch of static functions, and doesn't even include Tone.h, as these are defined in Arduino.h.

Sorry that this doesn't really offer much of a solution, I suppose you've either got to hunt down the cpp file that goes with Tone.h, or use the functions in the arduino library: http://arduino.cc/en/Reference/Tone
Logged

Portugal, Rio Tinto
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

You are right!

The h file and the cpp file are not made for each other.

re download them again, from the same site, and junt changed the include wires.h to arduino.h and it's working!

Sorry for any inconvenience!

btw, the thing working:
www.ruicaldas.com/downloads/OldPhoneFix.zip
Logged

Pages: [1]   Go Up
Jump to: