Last August I was experimenting with DTMF (dual-tone multi-frequency) and Arduino. I posted a video on YouTube that illustrates a proof-of-concept using the MT8870 tone decoder chip.
A few people have asked me to include the code and schematics for this demonstration: the code is below, and the schematics were derived from the MT8870 datasheet. Look for the figure titled “Single-Ended Input Configuration.”
/***********************************************************
DTMF Decoding with MT8870 chip
************************************************************/
int keyvalue; // the number associate with the tone
void setup()
{
Serial.begin(9600);
pinMode(6, INPUT); //input binary 1's digit from decoder chip
pinMode(7, INPUT); //input binary 2's digit from decoder chip
pinMode(8, INPUT); //input binary 4's digit from decoder chip
pinMode(9, INPUT); //input binary 8's digit from decoder chip
}
void loop()
// first determine the base ten value of the key, from 0-11
{
if (digitalRead(6) == HIGH) //if binary 1's is high
{
keyvalue = 1; //make keyvalue equal 1
}
else
{
keyvalue = 0; //otherwise make it zero
}
if (digitalRead(7) == HIGH) //if binary 2's is high
{
keyvalue = keyvalue + 2; //add "2" to keyvalue
}
if (digitalRead(8) == HIGH) //if binary 4's is high
{
keyvalue = keyvalue + 4; //add "4" to keyvalue
}
if (digitalRead(9) == HIGH) //if binary 8's is high
{
keyvalue = keyvalue + 8; //add "8" to keyvalue
}
// now convert keyvalues 9, 10 and 11 to "0", "*" and "#"
if (keyvalue == 10)
{
Serial.println("0"); //print zero key
}
else
{
if (keyvalue == 11)
{
Serial.println("*"); //print asterisk key
}
else
{
if (keyvalue == 12)
{
Serial.println("#"); //print pound key
}
else
{
Serial.println(keyvalue); //it isn't a special key so just print it
}
}
}
delay(100);
}
![]()
Decoding DTMF with Arduino and the MT8870 by Michael B LeBlanc is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 Canada License.
Permissions beyond the scope of this license may be available at mleblanc@nscad.ca.

