Hello, I am trying to write a program to play an MP3 file and a lamp to turn on at the same time. I'm using a DFPlayer Mini for the MP3 player, but I want to add an Ultrasonic Sensor to turn it on or off with a boolean. I have the sensor working but for the DFPlayer, I need to have a delay to play the song, so when I put my hand in front of the sensor, nothing happens. Does anyone know any way to perform an action while a delay is in action?
Yeah, I looked at that. The way the DFPlayer works is that you use the specific code "myDFPlayer.play();" but to play the song for longer than a second, you make a delay. if the delay is 5 seconds, the song plays for 5 seconds, if 100, then 100, but it needs to be a delay. So I'm trying to do something during that delay because I am planning on it being 100 seconds.
I think you are mistaken. The DFPlayer library has functions for starting to play, checking to see if the player is playing, pausing and resuming play, and stopping play. The 'delay()' just keeps you from sending a new play() command for some period of time. Please study the library and examples to see how you can continue to do other stuff while the player is playing.