I am making an alarm clock using a 4x20 lcd display, rtc, and Arduino Pro Mini 3.3v. I have implemented a menu system for setting the time/date that blinks the text on the lcd display to indicate that I have it selected, but the blinking randomly stops and the Arduino stops printing to the serial after about ten seconds.
After much head scratching and Googling I came to the conclusion that all my lcd.print() lines were using up all my ram. I tried to create PROGMEM variables to use in the print commands, but I couldn't get it to work so I ended up just adding the F() macro to every print statement (there's a lot). This now prints everything as expected, but the Arduino still freezes up after the same amount of time. Am I using F() wrong or is the problem something else like power???
Visual Studio code says I am using 643/2048 bytes of data/ram and 14960/30720 bytes of flash when I upload the code. (that is with the F() macro implemented)
--------------EDIT----------------
So I've created a small test sketch to use with the same circut, and now I'm really confused. I've been running it for about an hour now and it is still not freezing. The script blinks a full screen of number signs every 200ms. The backlight is on and everything is still powered the same way. This, in theory, rules out both running out of ram and not providing enough power. Any other ideas?
#include <Arduino.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <RTClibExtended.h>
LiquidCrystal_I2C lcd(0x27,20,4);
RTC_DS3231 clock;
void setup() {
Serial.begin (9600);
lcd.init();
clock.begin();
clock.adjust (DateTime (__DATE__, __TIME__));
lcd.backlight();
}
bool on = true;
void loop() {
lcd.setCursor (0, 0);
if (on) {
for (int i = 0; i < 4; i++) {
lcd.setCursor (0, i);
for (int j = 0; j < 20; j++) {
lcd.print ("#");
}
}
}
else {
for (int i = 0; i < 4; i++) {
lcd.setCursor (0, i);
for (int j = 0; j < 20; j++) {
lcd.print (" ");
}
}
}
on = !on;
delay (200);
}