I am using an OSEPP sound sensor (https://tinyurl.com/ybcvss49) to trigger files from an MP3 shield
(https://tinyurl.com/yc3g69gt) paired with an Arduino Uno at random. When the sound is above a certain threshold, the file is triggered. However, the Arduino occasionally crashes and I have to push the reset button manually to get it restarted.
I’m not sure which part of the code is causing the error. This only happens every so often, and being fairly new to the community I would appreciate any leads or suggestions on how to prevent this. I have attached the code and a schematic for the electronics.
Thank you in advance.
Kim_code_sound_sensor.ino (5.52 KB)
I have attached the code and a schematic for the electronics.
Well that schematic shows no connection between your microphone and the Arduino. In fact you connect the audio output of your microphone to the power of the MP3 wave player. And the Arduino is connected to nothing. Do you really have that or is that a crap schematic?
The code is a bit pedestrian and you could do better than that to make it a lot shorter but their is nothing that would obvious cause a crash.
If your random number was generated from 2 to 21 then you could simply append the number to a string variable to generate your file name. Note a string variable NOT a String variable. Case matters.
How is the SD memory reading when you compile it? Otherwise it is likely to be some sort of wiring problem like an intermittent connection or some form external interference.