0

I am using the DFRobotDFPlayerMini-1.0.1 library by Angelo. I am trying to use the actual RX TX pins on a Uno R3, but it doesn't connect unless I type in an alternate digital pin number. This is no good for my application as I have a major pin shortage. I have tried typing in (0,1) but that is not being accepted.

The reason for using this library is because it provides a LOOP function that works well.

  1. How do I use the RX TX pins with this library?
  2. Is there another library that has a good LOOP function in it?

Thanks.

Doug

1
  • Guys....I haven't posted code as this is a question more about Library function. thanks
    – Doug
    Commented Dec 31, 2016 at 12:44

2 Answers 2

1

On a classic Arduino pins 0 and 1 are used for serial communication with the host PC, so you cannot use them to talk to a peripheral without conflicting with that. The library may well be coded to trap and reject such an attempt.

On various alternate (ARM, Atmega32u4, etc) boards these pins may be usable, though the library may not be aware of that. Also on such boards you would generally want to use an available hardware UART rather than a software simulation of one, which may be fairly ATmega-specific anyway - the end result of which is that library code may well need modification to work on a non-traditional device.

5
  • Thanks Chris.....Yep...that seems to be the reason..the PWM usage is in conflict. I am working on an alternative using the DFPlayer 0nly...I will post final results in a couple of days hopefully.
    – Doug
    Commented Dec 31, 2016 at 12:41
  • PWM does not seem to have any role in the issue. The output of the DFPlayer may be PWM, but that doesn't touch the Arduino - the issue is with the Arduino's serial command communication to it. Commented Dec 31, 2016 at 18:21
  • Sorry Chris...Long Night and wrong post...the question is how do i get to use the RX TX pins on a UNO R3 with this Library....however You have answered the other question that I had.
    – Doug
    Commented Dec 31, 2016 at 21:49
  • You simply can't use them, unless you give up the connection to the PC. If you do that, you should re-write the library to use hardware serial. Commented Dec 31, 2016 at 22:00
  • 1
    Chris..this may be what the default :- software serial library is doing as it works on the RX TX pins #include <softwareserial.h> #include <dfplayer_mini_mp3.h> I have found several instances of this , example link stonez56.blogspot.com.au/2015/03/… but the problem is how do i LOOP with this library as that function is not well documented??? thanks
    – Doug
    Commented Dec 31, 2016 at 22:21
1

When you say "type in (0, 1)" I suppose you mean this:

#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;

Reference

You cannot use (0, 1) in SoftwareSerial. However, what you could do is pass Serial to the init string:

void setup() {
  // mySoftwareSerial.begin(9600);
  Serial.begin(9600);
  // if (!myDFPlayer.begin(mySoftwareSerial)) {
  if (!myDFPlayer.begin(Serial)) {
    //Use softwareSerial to communicate with mp3.
  }

However that means you cannot use Serial for debugging. You'll have to find another way to log errors and messages.

3
  • OK ...with library I have to select digital pins, thats just the way it is built. no options. thanks for the comments...closed
    – Doug
    Commented Jan 3, 2017 at 3:04
  • D0, D1 are digital pins. The problem is not there. See my answer.
    – dda
    Commented Jan 3, 2017 at 3:34
  • That true and i did try that but the library didn't like it..however with some round about coding i am now able to get an acceptable result for my project...thanks for the input.
    – Doug
    Commented Jan 3, 2017 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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