dtmf decoding

Hi good people..am new in the forum,but hav been viewing previous topics and I must appreciate ua constant support. Now, I got a slight problem concerning the interfacing of dtmf decoder mt8870 and the arduino Atmega 328. The hardware part of it is sorted out, the problem is the program code. The project is meant to do switchin of different devices such that when a certain key is pressed, a given device, say A, is switched on and wen another is pressed another key is pressed....around 4 devices. I must admit am not good in programming and therefore seeking ua assistance on the the coding pls. Ua response , highly appreciated.

You don't say what the "devices" are.

http://www.8051projects.info/exp11_2.asp

The devices are actually home appliances...Lightings in different room for example.the atmega should actually drive the 4 relays based on the decoded codes..

So, what's wrong with the program? You haven't posted anything.

Am actually blank on the programming, would u mind assisting me with a code example on the same

Well, I'd probably start by getting a very simple sketch working, just using "loop" to do a "digitalRead" of the signal pins from the decoder, and using the serial monitor to print the results.

Shouldn't be more than about 20 lines.

Don't forget to set the baud rate of the serial line in "setup", and initalise the pins as "INPUT"

The project is meant to do switchin of different devices such that when a certain key is pressed, a given device, say A, is switched on and wen another is pressed another key is pressed....around 4 devices.

You don't need DTMF to do this.

You don't need DTMF to do this.

Well, if it is something being controlled via an audio connection (telephone hand set or via something like ham radio), then it would be required.

The idea is to use the DTMF tones in switching....so I need to apply the technology

I had a DTMF project where I used 2 chips from Holtek - an HT9200B DTMF generator, and a HT9170B DTMF receiver. (Both are less than 70¢ each at Futurlec.)

The project is here. The schematic is here. Maybe it will help.

Thanx guyz... I hav developed the code to recognize the decoder outputs. next step is to use the decoded codes for controls, I also need the system to give an allowance to enter password. Guyz help develop the code, Actually I got 2 weeks to present my project. :

OK, Smalls, one more time:

POST

YOUR

CODE!

P.S. Use the ‘#’ button at the top of the posting window to do it.

The code for dtmf recognition and display below

define IRQ_PIN 2

define D0_PIN 3 // Recieve the data port binary 0

define D1_PIN 4 // Recieve the data port binary 1

define D2_PIN 5 // Recieve the data port binary 2

define D3_PIN 6 // Recieve the data port binary 3

byte irq_state;

void setup() { // Configura El Puerto Serial 9600,8,N,1 Serial.begin(9600);

// puts the port in Reading pinMode(IRQ_PIN, INPUT); pinMode(D0_PIN, INPUT); pinMode(D1_PIN, INPUT); pinMode(D2_PIN, INPUT); pinMode(D3_PIN, INPUT);

}

void loop() { // wait for the signal or tone irq_state = digitalRead(IRQ_PIN);

if ( irq_state == 1 ) {

Serial.print("Key : "); char key = read_codigo(); // Read the dtmf code Serial.println(key); // The key recieved prints delay(80); // pause to synchronize the signal / IRQ

} } /-------------------------------------------------------------/ byte read_codigo() { byte dato; // Variable that have the byte value of the key char key; // Variable that have the key xter

byte D0,D1,D2,D3; // Variable read state

// read the logic state variableMT8870 (1 o 0 , ON o OFF ) D0 = digitalRead(D0_PIN); D1 = digitalRead(D1_PIN); D2 = digitalRead(D2_PIN); D3 = digitalRead(D3_PIN);

// Cconverts binary to BYTE or Integer // Writes the bits in a variable data bitWrite(data,0,D0); bitWrite(data,1,D1); bitWrite(data,2,D2); bitWrite(data,3,D3);

// Turn the key to CHAR if ( data == 1 ) key = '1'; if ( data == 2 ) key = '2'; if ( data == 3 ) key = '3'; if ( data == 4 ) key = '4'; if ( data == 5 ) key = '5'; if ( data == 6 ) key = '6'; if ( data == 7 ) key = '7'; if ( data == 8 ) key = '8'; if ( data == 9 ) key = '9';

if ( data == 10 ) key = '0'; if ( data == 11 ) key = '*'; if ( data == 12 ) key = '#'; if ( data == 13 ) key = 'A'; if ( data == 14 ) key = 'B'; if ( data == 15 ) key = 'C'; if ( data == 0 ) key = 'D';

return key;

}

/-------------------------------------------------------------/ /-------------------------------------------------------------/

P.S. Use the '#' button at the top of the posting window to do it.

You can go back - if you click on "Modify", then highlight your code, then click on the "#" button, it'll save all out poor, sore scrolling fingers.

#define IRQ_PIN  2   
#define D0_PIN   3   // Recieve the data port binary 0
#define D1_PIN   4   // Recieve the data port binary 1
#define D2_PIN   5   // Recieve the data port binary 2
#define D3_PIN   6   // Recieve the data port binary 3


byte irq_state;

void setup()
{
// Configura El Puerto Serial 9600,8,N,1
Serial.begin(9600);

// puts the port in Reading
pinMode(IRQ_PIN, INPUT);
pinMode(D0_PIN, INPUT);
pinMode(D1_PIN, INPUT);
pinMode(D2_PIN, INPUT);
pinMode(D3_PIN, INPUT);
  
}

void loop()
{
// wait for the signal or tone
irq_state = digitalRead(IRQ_PIN);

if ( irq_state == 1 )
   {

     Serial.print("Key : ");
     char key = read_codigo(); // Read the dtmf code
     Serial.println(key); // The key recieved prints
     delay(80);          // pause to synchronize the signal / IRQ

   }
}
/*-------------------------------------------------------------*/
byte read_codigo()
{
byte dato;           // Variable that have the byte value of the key
char key;            // Variable that have the key xter


byte D0,D1,D2,D3;    // Variable read state

// read the logic state variableMT8870 (1 o 0 , ON o OFF )
D0 = digitalRead(D0_PIN);
D1 = digitalRead(D1_PIN);
D2 = digitalRead(D2_PIN);
D3 = digitalRead(D3_PIN);

// Cconverts binary to BYTE or Integer
// Writes the bits in a variable data
bitWrite(data,0,D0);
bitWrite(data,1,D1);
bitWrite(data,2,D2);
bitWrite(data,3,D3);

// Turn the key to CHAR
if ( data == 1  ) key = '1';
if ( data == 2  ) key = '2';
if ( data == 3  ) key = '3';
if ( data == 4  ) key = '4';
if ( data == 5  ) key = '5';
if ( data == 6  ) key = '6';
if ( data == 7  ) key = '7';
if ( data == 8  ) key = '8';
if ( data == 9  ) key = '9';

if ( data == 10 ) key = '0';
if ( data == 11 ) key = '*';
if ( data == 12 ) key = '#';
if ( data == 13 ) key = 'A';
if ( data == 14 ) key = 'B';
if ( data == 15 ) key = 'C';
if ( data == 0  ) key = 'D';

return key;

}

/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/