Timing problem with millis

@morteza20deris It took some before we understood the syncing problem, but I think that Delta_G is right.

If two timings are related, then I would use a single millis-timer.
Since the led is seen by the human eye, it is possible to run a millis-timer at a fixed rate (something 20...100Hz) and deal with the brightness in the millis-timer.

I have updated the Wokwi simulation to a Mega board: Timing problem with millis - Wokwi ESP32, STM32, Arduino Simulator

This is the sync problem after 2 minutes:
afbeelding

2 Likes