I'm trying to figure out a way to controll a DFplayer mini mp3 player with ADkeys.
Because I only have two or three files to play at a fixed volume I find it easier to just use the ADkeys. https://wiki.dfrobot.com/DFPlayer_Mini_SKU_DFR0299#target_4

enter image description here

Lets say I want to use Segment 1 - Segment 3 (MP3 file 1 - MP3 file 3). I would then connect a resistor (or none in Segment 1) in between and to three pins on the Arduino.
But how can I make the pin neutral, so that it does not trigger everything at once?
As far as I can read the pins are grounded in Arduino if not "high".

  • You mean “high impedance”? – Edgar Bonet Sep 2 '19 at 9:13
  • @EdgarBonet I was thinking as high as there is 5 volt, and low as grounded. Sorry for the confusion. – Andreas Sep 2 '19 at 9:29

What you are talking about in this instance is "Open Drain". Normally, as you rightly note, with outputs you have either HIGH or LOW, which effectively connects the output pin to +5V or GND respectively.

Instead you are asking for Open Drain. In this arrangement a pin is either "active", in which case it connects it to GND, or "inactive", in which case it is disconnected from (almost) anything.

Most 8-bit Arduino boards don't have Open Drain capability on their IO pins (some more advanced 32-bit boards do, though), but it is easy enough to emulate it in software.

You can emulate it using "Tri-State" logic. That is logic where, as well as HIGH and LOW you have "High Impedance", or "HI-Z". HI-Z is pretty much the same as "inactive" Open Drain. On the Arduino HI-Z is the same as INPUT.

So you can emulate it by:

  • To activate a pin set it to OUTPUT and LOW
  • To deactivate a pin set it to INPUT

For example, to "press" one of your buttons for 100ms you could:

pinMode(4, OUTPUT);
digitalWrite(4, LOW);
pinMode(4, INPUT);
  • I see! So setting the pin to input means it's waiting for input thus is neither. That's clever! – Andreas Sep 2 '19 at 9:49
  • 1
    @Andreas Actually technically the pin is always "waiting" for input. Setting it to INPUT mode just turns off the output driver circuitry and allows it to "see" the outside world. – Majenko Sep 2 '19 at 9:55

Your drawing appears to be attempting to provide analog levels to the DF miniplayer.

What you can do in that case is use two PWM outputs from the Arduino, with a RC lowpass filter to smooth the PWM into a DC level. (Arduino pin to 10K resistor, 4.7uF cap to gnd after that, the cap/resistor junction going to the DF Miniplayer).


analogWrite(pin, 128); // with pin being 3,5,6,9,10,11 on a Uno for example

to output 2.5V to the DF Miniplayer. Similarly, 64 would be about 1.25V, while 192 would be about 3.75V. Other levels are easily obtained.

  • 1
    Thank you for your answer but I believe you missed something. It's ground that the circuit is connected to, not a positive end. Or did I misunderstand you? – Andreas Sep 3 '19 at 20:20
  • The DF Miniplayer has some internal pullup resistor, yes? So connecting different value resistors from the pin to Gnd via switch creates a voltage divider and results in different voltages at the pin. How is that different than driving the pin with a voltage directly? Setup a few resistors, measure the voltage when pressed. See 3.5 of the Manual to see what buttons do github.com/Arduinolibrary/DFPlayer_Mini_mp3/raw/master/… – CrossRoads Sep 4 '19 at 2:23
  • To be honest I dont know. I don't have a clue what the internals are and how that is different. I don't have the knowledge. I can see a benefit of your answer if it works, but since I only need two or three then I'm fine with just using separate pins. – Andreas Sep 4 '19 at 6:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.