WordClock crashes within seconds when using SH1106 Oled and R/W a port.

Ok, i programmed a wordclock which drives 23 ledstrips to show the time in words.
It works fine with a SSD1306 Oled but i have quite a few SH1106 Oled’s, i like to use.
With the SH1106 it works fine UNTIL i read a value of an LDR attached to one of the Analog ports (i tried all with no result) AND/OR i write a calculated value from that value to adjust the light-intensity of the LED-strips with PWM… I also tried several PWM outputs without result.
The clock runs for 2 to 10 seconds and then freezes…
The sketch uses about 11k bytes program storage and about 500 bytes dynamic memory on my Arduino Uno.
The LEDstrips are driven through 3 shifregisters (74595N) and 3 drivers (ULN2803). Time comes from a I2C-DS3231, three switches to set time and brightness, a I2C-Oled, LDR/resistor.

What can cause this crashes? i did include some delays to see if it was a timing issue, but also no improvement…

When i uncomment <// analogWrite(PWM_PIN,PWM);> in the LDR_Brightness(void) subroutine, it is a matter of seconds…

Anyway this is my sketch: (some, but not all words are in Dutch :wink: )
Kees

WC1106.ino (10.1 KB)

How are you powering all this? Do you have a schematic (even a hand drawn one)?

Well, normaly the clock will be powered with a 12V/1A meanwell supply and the 5V is made from it with a standard 7805. But in this case i haven't attached the Led-strips, nor the shiftregisters or ULN-drivers. so this can be powered only over USB as the only load is the Arduino Uno, the stripped DS3231 (i removed the battery charger and the LED), the SH1106 OLED and one lowcurrent led to check the PWM..

BUT i made some improvement:

Although i didn't expect it to have effect i removed the void's between the brackets, so something like void DoSomething(void){ became void DoSomething(){.

After this only change i uploaded it to the Uno and now it seems to run for hours already.. :o

I haven't reversed it yet, to check if i can reproduce the error.. just let it run for a while...

Kees

I thought i solved it but the clock stops within 36 hours.. no single clue to solve it, other than to replace the SH1106 OLED for the SSD1306 OLED, which works perfect.. I'll have to find other projects to use this SH1106 apparently..

Kees