General

Help adding code to sample code for DTMF Shield *Pre order

userHead Account cancelled 2015-11-03 06:39:52 2748 Views1 Replies
Hi

I have a question before I buy the DTMF Shield

What I want to do is have the code "loop" until the DTMF Shield reads 8 DTMF tones
Then print them as a set, *not each individually as it reads them

Example:

If it read DTMF Tone 5
then DTMF Tone 4
then DTMF Tone 3
then DTMF tone 1
then DTMF tone 9
then DTMF tone 3
then DTMF tone 4
then DTMF tone 5

It would not have Serial.printed anything until it reached 8 "reads", but would print "54319345" all at once


I would use a "for I" with a "++" ??

here is the sample code

DTMF Arduino
Q1 12
Q2 11
Q3 10
Q4 9
STD 8
SPK2 3
SPK1 2

Q1~Q4 and STD are part of the DTMF demodulation interface. These pins are required for this board SPK pins are for an optional DTMF modulation from arduino. Which requires an alternative library for tone generation, read below for more details

Connection Diagram

For the Shield version, just stack it on an Arduino compatible device. If you are using the module, just wire the pins like the table above to your Arduino.




Sample Code


Code: Select all
/*
DTMF.cpp - Example code for DTMF library
Pin Diagram

DTMF Arduino
Q1 12
Q2 11
Q3 10
Q4 9
STD 8
SPK1 2
SPK2 3

*/



#include "dtmf.h"

DTMF dtmf;

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

void loop()
{
// Play a default number with all possibilities
//dtmf.playDTMF();

// Read DTMF codes one by one and print it on Serial
int myDtmf;
myDtmf = dtmf.getDTMF();
if(myDtmf != -1) Serial.println(myDtmf);
delay(80); // to avoid getting repeated output.
}

2015-11-03 19:17:16 Helllo,

Sure it can be done, I remember there was a function could adhere words to a string, but I don't remember. Anyway, it could also be realise by setting an array. You could make a judge wether the num is 8, if not, store them in the array, if yes, print the array.
userHeadPic Leff