Subscribe to Arduino Academy and start learning today for FREE!

Producing DTMF Tones

I wanted to teach my Arduino to talk telephone, so I added a HT9000A DTMF chip to produce the familiar “touch tones” (upcoming projects will act upon “heard” DTMF tones, but with a different chip).

The output is really low volume, so you may want to plug in amplified speakers or use an input on your stereo. You could build an amplifier circuit with a LM386 as well.

I used an Ham Radio program that listens for touch tones and displays the number it hears to verify operation. http://downloads.fyxm.net/DTMF-Decoder-47129.html

The code I used (and modified) was built by Brohogan.(don’t forget the include file)

Become the Maker you were born to be. Try Arduino Academy for FREE!

/* HT9200A DTMF Generator Test                             BroHogan 7/17/09
* SETUP FOR SERIAL MODE – Requires 3 pins – Data and Clock (100KHz) and CE
* Wire per data sheet – 3.57MHz xtal (4.0MHz won’t dial) S/P to GND = serial
* modified by Steve Spence – http://arduinotronics.blogspot.com
*/

#include <HT9200.h>                     // defines for HT9200 DTMF chip
#define DATA_PIN   2                    // Data (serial)
#define CLOCK_PIN  3                    // Clock (serial)
#define CE_PIN     4                    // Chip Enable pin (must control)

#define PHONE_NMBR “2642262”         // phone # to dial
char PhoneNum[] = PHONE_NMBR;           // load phone # for dialer

void setup() {
pinMode(DATA_PIN, OUTPUT);
pinMode(CLOCK_PIN, OUTPUT);
pinMode(CE_PIN, OUTPUT);
Init_HT9200();                        // init the chip
}

void loop() {
Dialer();                             // dials phone
delay(3000);
}

void Init_HT9200 (){
digitalWrite(CE_PIN, HIGH);           // start with chip disabled (else you go nuts)
digitalWrite(CLOCK_PIN, HIGH);        // start with clock pin high
digitalWrite(CE_PIN, LOW);            // now enable the chip
delay(10);                            // delay 10ms to ramp up the ocillator
DTMF_Out (DTMF_OFF,1,0);              // turn off any tone from previous run
}

void DTMF_Out (byte digit, long duration, long pause){  // FOR SERIAL COMM
if (digit == 0) digit = 10;           // take care of 0 here
for (byte i=0; i<5 br=”br” i=”i”>    digitalWrite(CLOCK_PIN, HIGH);      // clock high while setting data
digitalWrite(DATA_PIN, bitRead(digit,i)); // set data LSB->MSB
delayMicroseconds(5);               // 1/2 of 100K Clock speed
digitalWrite(CLOCK_PIN, LOW);       // clock low to latch data
delayMicroseconds(5);               // 1/2 of 100K Clock speed
}
delay(duration);                      // how long tone will play
if (pause != 0){                      // tone sounds continuously if zero
for (byte i=0; i<5 above=”above” as=”as” br=”br” i=”i” nbsp=”nbsp” same=”same”>      digitalWrite(CLOCK_PIN, HIGH);
digitalWrite(DATA_PIN, bitRead(DTMF_OFF,i));
delayMicroseconds(5);
digitalWrite(CLOCK_PIN, LOW);
delayMicroseconds(5);
}
delay(pause);                       // how long pause between tones
}
}

void Dialer(){  // dials tones from number
for (byte i=0; i<7 i=”i” nbsp=”nbsp” p=”p”> //i<7 11=”11″ 7=”7″ br=”br” digit=”digit” for=”for” i=”i” number=”number”>    DTMF_Out(PhoneNum[i]-‘0’,500,100);  // 1/2 sec tone with 1/10 pause
}
}

Become the Maker you were born to be. Try Arduino Academy for FREE!

</7></7></5></5>

Subscribe
Notify of
guest
5 Comments
Inline Feedbacks
View all comments
ramachandra ramu
5 years ago

fatal error: HT9200.h: No such file or directory

#include // defines for HT9200 DTMF chip

It shows me this error every time I try to compile this code.
if it is due to header file. where can i find this file?
i downloaded library but still there is no header file with it.

Steve Spence
5 years ago

The contents of the included file, HT9200.h, are posted in the link. That is the "library". You have to create the file with the below contents as mentioned in the forum:

/* HT9200.h defines for HT9200 DTMF chip in serial mode */

#define DTMF_OFF 24 // SB 31 but next cmd will be lost – a not used cmnd# works fine
#define STAR 11
#define POUND 12
#define A_KEY 13
#define B_KEY 14
#define C_KEY 15
#define D_KEY 0

// pure frequencies that can be made by the chip . . .
#define HZ_697 16
#define HZ_770 17
#define HZ_852 18
#define HZ_941 19
#define HZ_1209 20
#define HZ_1336 21
#define HZ_1477 22
#define HZ_1633 23

Müslüm kirmic
5 years ago

Im using arduino uno and ht9200a not work. no sound

Steve Spence
5 years ago

Audio output is low, should run it through a amplified speaker.

Aurimas Miko
5 years ago

Hi it worked for me, but I have strange like chirping noise, why is that? Thanks 🙂

Archives

5
0
Would love your thoughts, please comment.x
()
x