Atmeg328 as DTMF decoder affect digital pin6 output ?

Hi all,

I use Arduino UNO R3 to program Atmega328 as the DTMF decoder. And when detect the right keys, set a digital output to control a relay.

But it looks the DTMF command will affect UNO R3 board pin4 (That is Atmega328P pin6) output. The pin4 can't be controlled if the commend "dtmf.sample(sensorPin);" in the program. (You can masked this command by // to see the difference)

Other pins are OK (I tried pin5 or 6 are OK.)

Why the DTMF dtmf.sample(sensorPin) will affect the digital output pin4? Anyone has the experience?

The simplified codes are shown in below. You don't need to add anything, but use an LED+1K resistor connected between the output pin and GND, then can see pin4 LED is kept On and Off quickly....... pin5, or 6 are stable On as programmed.

UNO R3 pin4 is Atmega pin6 and is called (T0)PD4. Does DTMF use this pin for something?

#include <DTMF.h>

int sensorPin = A0; // ATmega328 pin 23.
float n=128.0;
float sampling_rate=8926.0;
DTMF dtmf = DTMF(n,sampling_rate);
float d_mags[8];

  int DoorOnOff1=4;           // Pin 4 DoorOnOff (Atmega328 pin 6)
  int DoorOnOff2=5;
  int DoorOnOff3=6;
  char key;
  
void setup()
    {
      pinMode(DoorOnOff1,OUTPUT);
      pinMode(DoorOnOff2,OUTPUT);
      pinMode(DoorOnOff3,OUTPUT);
      digitalWrite(DoorOnOff1, HIGH);          // Pin 4 Door OnOff control(Atmega328 pin 6) 
      digitalWrite(DoorOnOff2, HIGH); 
      digitalWrite(DoorOnOff3, HIGH);     
    }
   
void loop()
{
  dtmf.sample(sensorPin);                // This command will affect Pin 4 on/off.  Others pin are OK. 
  dtmf.detect(d_mags,736);
  key = dtmf.button(d_mags,680.);
  if(key)
  {  }
}

Hello, Can some one get a try on this? Very simple and easy to duplicate this symptom.

Just copy the simplified code I attached to run the program, no need to connect anything except an LED+1Kohm between UNO R3 pin4 (or Atmega328P pin6) and GND for checking. (Or You can also use Voltage-meter, or an oscilloscope to check the pin output) . Then you will see digital output pin4 will be out of controlled. (If LED, it will be On/Off continuously, If DC Voltage-meter, will be ~ 2.5V, If Oscilloscope, will see the voltage trace up and down......square wave)