ArduinoGeneral

DTMF shield cant seem to recognise string of digits

userHead Account cancelled 2017-02-19 12:04:40 1120 Views0 Replies
In my project, I am using the DFrobot DTMF shield (mounted on an arduino uno) with a phone shield (also mounted onto another arduino uno and a XBee unit). Basically, the DTMF shield would recognise the digits input from the phone shield and if it recognises the digit '1', it will trigger the attached wireless XBee to send a signal.

At the moment, my project works if there is only one number input ie. '1'. However, when I tried to modify my code for recognising a string of digits ie. '1,5' this would not work. I appreciate any advice on how I can overcome this issue.

Many thanks!

Here is the code for my DTMF shield:

[code]
#include "SoftwareSerial.h"
#include "dtmf.h"

DTMF dtmf; // default set to DFRobot DTMF board pins, Speaker pins

SoftwareSerial XBee(2, 3);

void setup()
{
Serial.begin(9600);
XBee.begin(9600);
}

void loop()
{
int myDtmf;
myDtmf = dtmf.getDTMF();
if(myDtmf != -1) Serial.println(myDtmf);
if (myDtmf ==1){
if (myDtmf ==5){ //When this is added, it cannot work
XBee.write('1');
}
}
delay(80); // to avoid getting repeated output.
}
[/code]