My concern is that the delay(15000) would be blocking execution for anything else - making it difficult to listen for an interrupt. MyDFPlayer.disableLoopAll() - stops all playing MP3's 2 for third, and so forth.ĭelay(15000) - delay for 15 seconds (will eventually be set to a minute unless an alternate solution is found. The key to keep in mind is that a do-while always makes at least one pass through the loop regardless of the test condition(s) at the bottom of the loop. ayMp3Folder(1) - play the second file in the MP3 folder. The moral of the story Dont use do/while. MyDFPlayer.enableLoop() - this will enable the MP3 to be played on a loop. I need a way to stop this thing if need be.Īs you can see from the code above, the thing essentially captures the button state, and then plays the appropriate sound sample for whatever button was pressed (button 2 - 7). The trouble is - this thing will be playing these sound samples through a set of 6 amplified loudspeakers, at around 131dB. You are also not looking at the Wifi interface during the while loop so there is no way to tell the loop to stop anyway. From what I understand, when the while loop condition is not true(so the button is pressed) it should end the loop and continue with the rest of the code. I am running the buttons using the built in pullup resistor so the the button is not pressed when HIGH and pressed when LOW. Neither of these will change during the running of the while loop, so it does not exit. After browsing through some forums, I found out that the simplest way to do this is with a while loop. Here is some of the code, with other buttons edited out for brevity: void setup()īyte buttonState2 = digitalRead(BUTTON_PIN2) īyte buttonState3 = digitalRead(BUTTON_PIN3) The exit from the while loop is when Blink true and you also have a statement to break when pinNumber 000. Interestingly this while loop only runs once and then goes back to the top of void. To check parts of the code, i have placed an infinite while loop after the serial communication is done. on the Arduino code no matter what i do or command after the serial run, it skips through it. I am sending strings via serial port to and from a python program. I am creating a module that will essentially read 6 INPUT buttons which will trigger an audio file to play on a loop within the DFRobot MP3 Player: Hi there I am fairly new to arduino coding.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |