DFRobotPlayerMini RC Remote control coding issue.

With this code, the desired outcome is to use a ATTiny85 chip with a DFRobotPlayerMini MP3 in order to play 8 songs one way and 8 songs an other way with a toggle two way switch on an RC controller.

The current code i have come up with for the project, only works playing the next song on the high value but when trying to implement the feature to play the previous song on the low value, it constantly loops all the songs on the mp3 player continuously . I also want to implement a feature where if i where to hold the switch one way the volume goes up and the other way it goes down.

I’ve tried different librarys for the DFRobotMiniPlayer to see if would I have any success but I am constantly facing the same issue.

I’ve attached the code for this project in hopes of someone being able to help. I’ve also attached the link to the DFPlayer_Mini_Mp3 library that is being used in this project. (GitHub - DFRobot/DFPlayer-Mini-mp3)

#include <SoftwareSerial.h>
#include “DFPlayer_Mini_Mp3.h”

SoftwareSerial mySerial(4, 3); // RX, TX

int data1;

void setup(){
Serial.begin (9600);
mySerial.begin (9600);
mp3_set_serial (mySerial); //set softwareSerial for DFPlayer-mini mp3 module
delay(2); //wait 1ms for mp3 module to set volume
mp3_set_volume (5);

pinMode(2, INPUT);

}
void loop(){

data1=pulseIn(2,HIGH);if (data1>1750)mp3_next ();else mp3_stop (); // this does work
delay (2000);

data1=pulseIn(2,LOW);if (data1>1250)mp3_prev ();else mp3_stop (); // this does not work, this is the issue so far.
delay (2000);

}

Pulsin seems an odd choice to detect the state of a switch. Why not use digitalRead?

data1=DigitalRead(2,HIGH);if (data1>1750)mp3_next ();else mp3_stop (); (DigitalRead Does not work with the current library. Stays Grayed out?)

The switch works via a reciever using PWM signal.

rchobbiesandstuff:
data1=DigitalRead(2,HIGH);if (data1>1750)mp3_next ();else mp3_stop (); (DigitalRead Does not work with the current library. Stays Grayed out?)

The switch works via a reciever using PWM signal.

Don't forget that C++ is case sensitive. It's digitalRead. But if you're reading PWM, pulseIn was probably the better choice anyway.

Cheers for the reply. Would you have any other suggestions that could help?

What is the signal from the switch? Is it just one pulse?

Its a PWM pulse from an rc reciever.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.