element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Introducing DFPlayer module to working project breaks code
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 13 replies
  • Subscribers 385 subscribers
  • Views 2547 views
  • Users 0 members are here
  • dfplayer
  • arduino mega 2560
  • arduino_code
Related

Introducing DFPlayer module to working project breaks code

colporteur
colporteur over 2 years ago

I am trying to add sound to the fireworks light project I used for a Project 14 Challenge. The project uses an Arduino Mega 2560 knockoff microcontroller.

I’ve added a DFPlayer Mini hardware and plan to use the DFRobotDFPlayerMini library. I have used this hardware and library combination before with some success.

When this instruction is called

  if (!myDFPlayer.begin(mySoftwareSerial)) {  //Use softwareSerial to communicate with mp3.
    Serial.println(F("Unable to begin. Check connection and SD card, or reset the Arduino."));
    while (true)
      ;
  }

I get one string of lights flashing and nothing else works.

#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
#include <RGBLed.h>

//define array of output pins for ease of setup
const byte aryPins[] = { 21, 22, 23, 24, 25, 26, 27,
                         28, 29, 30, 31, 32, 33, 34, 35, 36,
                         37, 38, 39, 40, 41, 42, 43, 44, 45,
                         46, 47, 48, 49, 50, 51, 52, 53 };

RGBLed b1r1LED(53, 51, 49, RGBLed::COMMON_CATHODE);  //assign three pins to each RGBLED
RGBLed b1r2LED(47, 45, 43, RGBLed::COMMON_CATHODE);
RGBLed b1r3LED(41, 39, 37, RGBLed::COMMON_CATHODE);
RGBLed b2r1LED(35, 33, 31, RGBLed::COMMON_CATHODE);
RGBLed b2r2LED(29, 27, 25, RGBLed::COMMON_CATHODE);
RGBLed b2r3LED(23, 24, 22, RGBLed::COMMON_CATHODE);
RGBLed b3r1LED(52, 50, 48, RGBLed::COMMON_CATHODE);
RGBLed b3r2LED(46, 44, 42, RGBLed::COMMON_CATHODE);
RGBLed b3r3LED(40, 38, 36, RGBLed::COMMON_CATHODE);
RGBLed sparklerLED(30, 32, 34, RGBLed::COMMON_CATHODE);
/*
const byte sparkle_LED1 = 30;//assign pins to each single LED
const byte sparkle_LED2 = 32;
const byte sparkle_LED3 = 34;
*/

const byte ButtonPin = 28;  //assign pin to input button to start fireworks
const byte LEDStrip1 = 19;  //assign pin to output trigger of sequential LED's for burst1
const byte LEDStrip2 = 20;  //assign pin to output trigger of sequential LED's for burst2

const byte INITIAL_VALUE = LOW;  //The initial state of all Outputs. Can be LOW or HIGH.


//setup DF Player
int rxPin = 10;    // DFplayer RX to Arduino pin 10
int txPin = 11;    // DFplayer TX toArduinopin 11
int busyPin = 12;  // DFplayer BUSY connected to pin 12

SoftwareSerial mySoftwareSerial(rxPin, txPin);
DFRobotDFPlayerMini myDFPlayer;


//define array of RGB colours
int* getRandomRGBColor() {
  static int(*r);  // pointer variable

  switch (rand() % 7) {
    case 0: r = RGBLed::BLUE; break;
    case 1: r = RGBLed::GREEN; break;
    case 2: r = RGBLed::CYAN; break;
    case 3: r = RGBLed::RED; break;
    case 4: r = RGBLed::MAGENTA; break;
    case 5: r = RGBLed::YELLOW; break;
    case 6: r = RGBLed::WHITE; break;
  };
  return r;
};

void setup() {
  //Initiate Serial communication.
  Serial.begin(9600);
  Serial.begin(115200);
  Serial.println(F("Initializing DFPlayer..."));

  if (!myDFPlayer.begin(mySoftwareSerial)) {  //Use softwareSerial to communicate with mp3.
    Serial.println(F("Unable to begin. Check connection and SD card, or reset the Arduino."));
    while (true)
      ;
  }
 /*
  Serial.println(F("DFPlayer Mini online."));
  myDFPlayer.setTimeOut(500);                   // Set serial communictaion time out 500ms
  myDFPlayer.volume(25);                        // Set volume value (0~30).
  myDFPlayer.EQ(DFPLAYER_EQ_BASS);              // Set EQ to BASS (normal/pop/rock/jazz/classic/bass)
  myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD);  // Set device we use SD as default
  myDFPlayer.enableDAC();                       // Enable On-chip DAC
*/

  for (int i = 0; i < sizeof aryPins; i++) {  //Go through all LED pins
    pinMode(aryPins[i], OUTPUT);              //Make them outputs
    digitalWrite(aryPins[i], INITIAL_VALUE);  //And set them to their initial value which is OFF
  }

  pinMode(ButtonPin, INPUT_PULLUP);  //Set the switch's pin to be an input with a pullup (default is HIGH)
                                     // pinMode(busyPin, INPUT);
}

void loop() {
  //  int soundFile = random(1, 4);  // multi soundfiles: 0001.mp3...0012.mp3
  //int soundFile = 1;              // single soundfile: 0001.mp3

  if (digitalRead(ButtonPin) == HIGH) {  //Test button pin to set off fireworks
    return HIGH;
  } else {
    randomSeed(analogRead(0));
    int burst_orderIdx = rand() % 3;  //random number 1-3 to determine what burst sequence will run

    if (burst_orderIdx == 1) {
      Serial.println(F("Start fireworks burst pattern 1,2,3"));
      //LED Strip 1 launch
      digitalWrite(LEDStrip1, HIGH);
      delay(250);
      digitalWrite(LEDStrip1, LOW);

      //Burst 1 On
      b1r1LED.setColor(getRandomRGBColor());
      delay(500);
      b1r2LED.setColor(getRandomRGBColor());
      delay(500);
      b1r3LED.setColor(getRandomRGBColor());
      delay(1000);

      //Burst 1 Off
      b1r1LED.off();
      b1r2LED.off();
      b1r3LED.off();
      delay(3000);
      Serial.println(F("Burst 1 completed "));

      //LED Strip 2 launch
      digitalWrite(LEDStrip2, HIGH);
      delay(250);
      digitalWrite(LEDStrip2, LOW);

      //Burst 2 On
      b2r1LED.setColor(getRandomRGBColor());
      delay(500);
      b2r2LED.setColor(getRandomRGBColor());
      delay(500);
      b2r3LED.setColor(getRandomRGBColor());
      delay(1000);

      //Burst 2 Off
      b2r1LED.off();
      b2r2LED.off();
      b2r3LED.off();
      delay(3000);
      Serial.println(F("Burst 2 completed "));

      //Burst 3 On
      b3r1LED.setColor(getRandomRGBColor());
      delay(500);
      b3r2LED.setColor(getRandomRGBColor());
      delay(500);
      b3r3LED.setColor(getRandomRGBColor());
      //delay(500);

      //Sparklers
      for (int n = 1; n <= 3; n++)  // Count to five
      {
        sparklerLED.fadeIn(255, 0, 0, 10, 100);
        delay(100);
        sparklerLED.fadeOut(255, 0, 0, 10, 100);
        delay(100);
        sparklerLED.fadeIn(0, 255, 0, 10, 100);
        delay(100);
        sparklerLED.fadeOut(0, 255, 0, 10, 100);
        delay(100);
        sparklerLED.fadeIn(0, 0, 255, 10, 100);
        delay(100);
        sparklerLED.fadeOut(0, 0, 255, 10, 100);
        delay(100);
      }

      //Burst 3 Off
      b3r1LED.off();
      b3r2LED.off();
      b3r3LED.off();
      delay(1000);
      Serial.println(F("Burst 3 completed "));
      Serial.println(F("End fireworks burst pattern 1,2,3"));
    } else if (burst_orderIdx == 2) {
      Serial.println(F("Start fireworks burst pattern 2,3,1"));

      //LED Strip 2 launch
      digitalWrite(LEDStrip2, HIGH);
      delay(250);
      digitalWrite(LEDStrip2, LOW);

      //Burst 2 On
      b2r1LED.setColor(getRandomRGBColor());
      delay(500);
      b2r2LED.setColor(getRandomRGBColor());
      delay(500);
      b2r3LED.setColor(getRandomRGBColor());
      delay(1000);

      //Burst 2 Off
      b2r1LED.off();
      b2r2LED.off();
      b2r3LED.off();
      delay(3000);
      Serial.println(F("Burst 2 completed "));

      //Burst 3 On
      b3r1LED.setColor(getRandomRGBColor());
      delay(500);
      b3r2LED.setColor(getRandomRGBColor());
      delay(500);
      b3r3LED.setColor(getRandomRGBColor());
      //delay(500);

      //Sparklers
      for (int n = 1; n <= 3; n++)  // Count to five
      {
        sparklerLED.fadeIn(255, 0, 0, 10, 100);
        delay(100);
        sparklerLED.fadeOut(255, 0, 0, 10, 100);
        delay(100);
        sparklerLED.fadeIn(0, 255, 0, 10, 100);
        delay(100);
        sparklerLED.fadeOut(0, 255, 0, 10, 100);
        delay(100);
        sparklerLED.fadeIn(0, 0, 255, 10, 100);
        delay(100);
        sparklerLED.fadeOut(0, 0, 255, 10, 100);
        delay(100);
      }

      //Burst 3 Off
      b3r1LED.off();
      b3r2LED.off();
      b3r3LED.off();
      delay(1000);
      Serial.println(F("Burst 3 completed "));

      //LED Strip 1 launch
      digitalWrite(LEDStrip1, HIGH);
      delay(250);
      digitalWrite(LEDStrip1, LOW);

      //Burst 1 On
      b1r1LED.setColor(getRandomRGBColor());
      delay(500);
      b1r2LED.setColor(getRandomRGBColor());
      delay(500);
      b1r3LED.setColor(getRandomRGBColor());
      delay(1000);

      //Burst 1 Off
      b1r1LED.off();
      b1r2LED.off();
      b1r3LED.off();
      delay(3000);
      Serial.println(F("Burst 1 completed "));
      Serial.println(F("End fireworks burst pattern 2,3,1"));
    } else {
      Serial.println(F("Start fireworks burst pattern 3,1,2,"));

      //Burst 3 On
      b3r1LED.setColor(getRandomRGBColor());
      delay(500);
      b3r2LED.setColor(getRandomRGBColor());
      delay(500);
      b3r3LED.setColor(getRandomRGBColor());
      //delay(500);

      //Sparklers
      for (int n = 1; n <= 3; n++)  // Count to five
      {
        sparklerLED.fadeIn(255, 0, 0, 10, 100);
        delay(100);
        sparklerLED.fadeOut(255, 0, 0, 10, 100);
        delay(100);
        sparklerLED.fadeIn(0, 255, 0, 10, 100);
        delay(100);
        sparklerLED.fadeOut(0, 255, 0, 10, 100);
        delay(100);
        sparklerLED.fadeIn(0, 0, 255, 10, 100);
        delay(100);
        sparklerLED.fadeOut(0, 0, 255, 10, 100);
        delay(100);
      }

      //Burst 3 Off
      b3r1LED.off();
      b3r2LED.off();
      b3r3LED.off();
      delay(1000);
      Serial.println(F("Burst 3 completed "));

      //LED Strip 1 launch
      digitalWrite(LEDStrip1, HIGH);
      delay(250);
      digitalWrite(LEDStrip1, LOW);

      //Burst 1 On
      b1r1LED.setColor(getRandomRGBColor());
      delay(500);
      b1r2LED.setColor(getRandomRGBColor());
      delay(500);
      b1r3LED.setColor(getRandomRGBColor());
      delay(1000);

      //Burst 1 Off
      b1r1LED.off();
      b1r2LED.off();
      b1r3LED.off();
      delay(3000);
      Serial.println(F("Burst 1 completed "));

      //LED Strip 2 launch
      digitalWrite(LEDStrip2, HIGH);
      delay(250);
      digitalWrite(LEDStrip2, LOW);

      //Burst 2 On
      b2r1LED.setColor(getRandomRGBColor());
      delay(500);
      b2r2LED.setColor(getRandomRGBColor());
      delay(500);
      b2r3LED.setColor(getRandomRGBColor());
      delay(1000);

      //Burst 2 Off
      b2r1LED.off();
      b2r2LED.off();
      b2r3LED.off();
      delay(3000);
      Serial.println(F("Burst 2 completed "));
      Serial.println(F("End fireworks burst pattern 3,1,2"));
    }
  }
}


I have used a process of elimination (i.e. adding /* & */) to isolate the code that is causing me problems.

I have used this same code snipit in another project. It worked but was not combined with something else.

I am a code resurrectionist not a programmer or coder. I usually cut and paste code parts to develop a working project. Minds more familiar with Arduino have helped me solve problems in the past when I make code changes without fully understanding the underlying infrastructure. 

I'm at the point of using another sound solution. This would be a pain-in-the-***. I would have to go back in and redesign the PCB. I made this attempt to add sound about six months ago without success. I settled for the light show only, promising myself I would go back and find a solution. When I revisited it recently I did find some coding errors that I made but nothing that contributed to the current problem I am having.

I've included the full code if that helps. am hoping someone could give me some insight. Why when this line of code stops everything?

  • Sign in to reply
  • Cancel

Top Replies

  • JWx
    JWx over 2 years ago +3
    does it print "Unable to begin. Check connection and SD card, or reset the Arduino" on serial console? Because it would be exactly what it is supposed to do - print error message then enter infinite…
  • colporteur
    colporteur over 2 years ago +2
    Problem(s) discovered here are the fixes. I can get the DFPlayer working with the Mega. After bench testing a DFPlayer to Mega configuration I used the knowledge to troubleshoot the fireworks setup…
  • Andrew J
    Andrew J over 2 years ago in reply to jc2048 +1
    Returning a value is an unnecessary piece of code in Arduino C because loop() is continuously called. Behind the scenes I suspect there is an auto-generated function main() that first calls setup(), then…
Parents
  • robogary
    robogary over 2 years ago

    I run into these problems when pasting in pieces of working example code. It seems often the libraries leverage the timers and interrupts, create conflicts or corrupting timer data, and the compiler doesn't see the operation as illegal.

    Also, your code has 2 serial.begin lines.

    In some cases like a ping sensor, it is simple enough to write my own code.

    In more complex library objects, I will be a coward and add another controller like a Arduino Nano to control the DFplayer. I'll hardwire a discrete interface between the 2 controllers. Some projects even make sense to partition the hardware into interconnected modules, and also avoid killing myself trying to get SW modules to play nice together. 

    You can use digital outputs  to select multiple tracks to play , either directly hardwired to DFplayer, or BCD style to a second controller interfaced to the DFplayer.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • colporteur
    colporteur over 2 years ago in reply to robogary

    I've had to take a step back after this morning. The simple DFPlayer code I use on a Nano (Tested again this morning) doesn't work on the mega. Same pins are used on for both. I have a spare mega at another location that I need to get to confirm if the same problem exists on that unit.

    #include "Arduino.h"
    #include "SoftwareSerial.h"
    #include "DFRobotDFPlayerMini.h"
    
    int ledPin = 13;                   // LEDs (via MOSFET) connected to pin 9
    int rxPin = 10;                   // DFplayer RX to Arduino pin 10
    int txPin = 11;                   // DFplayer TX toArduinopin 11
    int busyPin = 12;                 // DFplayer BUSY connected to pin 12
    int buttonPin = 8;                // Button to trigger animation
    
    
    SoftwareSerial mySoftwareSerial(rxPin, txPin);
    DFRobotDFPlayerMini myDFPlayer;
    
    void setup()
    {
    
      pinMode(ledPin, OUTPUT);
      pinMode(busyPin, INPUT);
      pinMode(buttonPin, INPUT);
    
      mySoftwareSerial.begin(9600);
      Serial.begin(115200);
      Serial.println(F("Initializing DFPlayer..."));
    
      if (!myDFPlayer.begin(mySoftwareSerial)) {  //Use softwareSerial to communicate with mp3.
        Serial.println(F("Unable to begin. Check connection and SD card, or reset the Arduino."));
        while (true);
      }
    
      Serial.println(F("DFPlayer Mini online."));
    
      myDFPlayer.setTimeOut(500);                   // Set serial communictaion time out 500ms
      myDFPlayer.volume(25);                        // Set volume value (0~30).
      myDFPlayer.EQ(DFPLAYER_EQ_BASS);              // Set EQ to BASS (normal/pop/rock/jazz/classic/bass)
      myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD);  // Set device we use SD as default
      myDFPlayer.enableDAC();                       // Enable On-chip DAC
    }
    
    void loop()
    {
    int soundFile = random(1, 4);   // multi soundfiles: 0001.mp3...0012.mp3
    //int soundFile = 1;              // single soundfile: 0001.mp3
      
    
    if (digitalRead(buttonPin) == HIGH)                  // Trigger animation when button pressed
    {
      {
      digitalWrite(ledPin, HIGH);                       // Turn LED strip on
      myDFPlayer.playMp3Folder(soundFile);
      delay(1000);                                   // Give the DFPlayer some time
    
      while (digitalRead(busyPin) == LOW) {          // Wait for the DFPlayer to finish playing the MP3 file
      }
      digitalWrite(ledPin, LOW);                       // Turn the LED strip off
      delay(1000);
      }
    }
    }
    

    This is a simple block of code that I used with Nano's. It was taken from some grave of other code. I acknowledge it could use some improvements. It worked and has worked reliably up to this point. Moving across different hardware I didn't think it would be a problem. I always use the DFPlayer with Nano (knockoffs) without issue. This is the first time I have used it with a Mega.  I made a whole bunch of assumptions going in that may not be valid.

    Your deep insight into underlying infrastructure has merit. Those sort of things have bitten me in the *** in the past.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • colporteur
    colporteur over 2 years ago in reply to robogary

    I've had to take a step back after this morning. The simple DFPlayer code I use on a Nano (Tested again this morning) doesn't work on the mega. Same pins are used on for both. I have a spare mega at another location that I need to get to confirm if the same problem exists on that unit.

    #include "Arduino.h"
    #include "SoftwareSerial.h"
    #include "DFRobotDFPlayerMini.h"
    
    int ledPin = 13;                   // LEDs (via MOSFET) connected to pin 9
    int rxPin = 10;                   // DFplayer RX to Arduino pin 10
    int txPin = 11;                   // DFplayer TX toArduinopin 11
    int busyPin = 12;                 // DFplayer BUSY connected to pin 12
    int buttonPin = 8;                // Button to trigger animation
    
    
    SoftwareSerial mySoftwareSerial(rxPin, txPin);
    DFRobotDFPlayerMini myDFPlayer;
    
    void setup()
    {
    
      pinMode(ledPin, OUTPUT);
      pinMode(busyPin, INPUT);
      pinMode(buttonPin, INPUT);
    
      mySoftwareSerial.begin(9600);
      Serial.begin(115200);
      Serial.println(F("Initializing DFPlayer..."));
    
      if (!myDFPlayer.begin(mySoftwareSerial)) {  //Use softwareSerial to communicate with mp3.
        Serial.println(F("Unable to begin. Check connection and SD card, or reset the Arduino."));
        while (true);
      }
    
      Serial.println(F("DFPlayer Mini online."));
    
      myDFPlayer.setTimeOut(500);                   // Set serial communictaion time out 500ms
      myDFPlayer.volume(25);                        // Set volume value (0~30).
      myDFPlayer.EQ(DFPLAYER_EQ_BASS);              // Set EQ to BASS (normal/pop/rock/jazz/classic/bass)
      myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD);  // Set device we use SD as default
      myDFPlayer.enableDAC();                       // Enable On-chip DAC
    }
    
    void loop()
    {
    int soundFile = random(1, 4);   // multi soundfiles: 0001.mp3...0012.mp3
    //int soundFile = 1;              // single soundfile: 0001.mp3
      
    
    if (digitalRead(buttonPin) == HIGH)                  // Trigger animation when button pressed
    {
      {
      digitalWrite(ledPin, HIGH);                       // Turn LED strip on
      myDFPlayer.playMp3Folder(soundFile);
      delay(1000);                                   // Give the DFPlayer some time
    
      while (digitalRead(busyPin) == LOW) {          // Wait for the DFPlayer to finish playing the MP3 file
      }
      digitalWrite(ledPin, LOW);                       // Turn the LED strip off
      delay(1000);
      }
    }
    }
    

    This is a simple block of code that I used with Nano's. It was taken from some grave of other code. I acknowledge it could use some improvements. It worked and has worked reliably up to this point. Moving across different hardware I didn't think it would be a problem. I always use the DFPlayer with Nano (knockoffs) without issue. This is the first time I have used it with a Mega.  I made a whole bunch of assumptions going in that may not be valid.

    Your deep insight into underlying infrastructure has merit. Those sort of things have bitten me in the *** in the past.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
Children
  • robogary
    robogary over 2 years ago in reply to colporteur

    Yay ! It feels good to be a little helpful.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • baldengineer
    baldengineer over 2 years ago in reply to colporteur

    In this code, you are not using the internal pull-up resistor for the buttonPin. You were, however, using it for at it on the previous code.

    Since you are looking for when the buttonPin goes HIGH, do you have an external pull-down resistor on that pin with the other side of the button connected to 5V? If not, it is floating.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • colporteur
    colporteur over 2 years ago in reply to baldengineer

    Yes, there is a pulldown resistor. I have used a combination of both 5V and Gnd triggers. I would like to have been more consistent but it has been a live and learn exercise. The LED fireworks light show operates as expected. It is when I add the DFPLayer code it goes south.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • JWx
    JWx over 2 years ago in reply to colporteur

    working code has:

      mySoftwareSerial.begin(9600);
      Serial.begin(115200);

    hanging code is different:

      Serial.begin(9600);
      Serial.begin(115200);

    maybe it's it? Player initialization not finishing and entering infinite loop because of not working software serial?

    and - as robogary mentioned - if it doesn't help, maybe there is some resource conflict inside libraries - in this case I would use hardware UART of mega256 (it has four of them) - it probably consumes less shared resources of MCU

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube