I'm really enthusiastic about Arduino and Coding it, but still quite a noob... I have a problem, which I'm almost certain is due to my code: The Arduino is freezing (at random moments).
Type of project:
Creating a word clock, similar to: Arduino Word Clock : 31 Steps (with Pictures) - Instructables
I'm using WS2812B led strips to light the letters. Because of the distance in between the letters (50mm), I need to use the 60 leds/m variants (distance = 16mm in between the LEDs) and only light up 1 out of every 4 (4 * 16 = 52mm)
Type of Arduino:
NANO 33 IoT (real one, no Alibaba fake)
components in use:
Powerbank 5V (20.000ma) + WS2812B Led strips + RTCDS3231 + Radar RCWL-051 + Push buttons + LDR sensor
- The Arduino/system freezes after random moments of time when it's turned on. Sometimes after 20 minutes, sometimes after 5 hours or so. The LEDs are still on, but all sensors/buttons stop working and the time isn't updated anymore.
If I turn the power down and back up again, the time is updated (on most occasions) but will not continue to run (stands on the same time forever..)
- If I want to adjust the time, I can add about 3/4 minutes or hours before the Arduino freezes. Also, when it's connected to my PC, the connection is lost.
On both occasions described above, I need to connect the Arduino to my PC, hit the reset button, and upload the example blink sketch simultaneously to have it working / available again.
What I'm trying to accomplish
- Stable running word clock so I can mount it to my wall forever..
- With the buttons I want to be able to adjust the color of the letters (Pin 9, via multiple pre-sets) and the time (pin 2 and 3)
- The LDR sensor should set the right brightness to the letters, matching the surrounding room brightness
- The motion sensor should turn the LEDs off after 30 minutes of no movement, saving power of the power bank
I already tried to learn as much as possible from examples and reading/searching for other codes, but after many frustrating nights, I can't find my way out, unfortunately..
Any help is really appreciated, you will be my hero
Any tips on optimizing the code are welcome as well, I'm still trying to learn as much as possible.. (string of I (min.&hours) is really, really long for example)
Link to code: Wordclock_Code_V2.ino - Google Drive
Thank you in advance!