Subdivided and synchronized LED Outputs

Hi,

Long time lurker, first time poster :D

I'm having trouble putting together some of my code for a project that I'm working on.

The basic idea is using this bit of code to detect low frequency pulses (~5Hz down to ~0.1Hz), store that info into a variable, then use that variable to set the frequency of three pulsed outputs of the same frequency as the input, which can be subdivided by simple integers (2, 3, 4, etc.).

I've looked for various bits of code for flashing LED's at different rates, my favorite one being this one.

The problem that I'm having is that whenever I update my divisors, the LED's seem to no longer be synchronized.

I'm probably being a bit pedantic trying to achieve this, but for my project I think it's best. I'm sure this is probably a relatively easy thing to do, but I'm super new to Arduino/microcontrollers. I have a decent understanding of programming, but as I'm new to this, I'm still pretty limited. I'm pretty sure this is a limitation of my knowledge of the subject at hand and not the Arduino itself.

Any advice? Apologies if there are threads covering this already...I spent the better part of yesterday scouring the forums and didn't quite run across a solution.

Currently using a Rev 3 Uno. Thanks for any advice!

As an example…

The attached sketch starts blinking two LED’s at a specified rate.

After 5 seconds, it divides the rate by two different integers, then returns to the initial divisors after another 5 seconds…however the LED’s are no longer synchronized with each other.

Blink_Subdivision.ino (1.66 KB)