Synchronizing more than one Arduinos together

Hi there,

I have been looking at different forum topics, and was unable to find this topic so I am putting it up myself.

My application requires me producing a lot of PWM signals (about 20 odd). I understand that I can put two or more Arduinos together and get them to produce the required PWM signals.

However, it would be very useful if all the PWM signals are synced together.

Is there a way to do this? I think this is the right forum to be in, as this is a networking issue.

My thoughts so far have been using interrupts, but I do not yet know how to proceed from there on.

I normally use PWM signals by going into Timer 1 (or 3,4,5), adjusting values of registers to give me a better frequency, using ICR and OCR registers. I have a suspicion that doing that with a constantly running interrupt may disrupt the clock signals.

Anybody have any experience with this?

Any feedback is highly appreciated.


You don’t even do this with a standard Arduino in its normal configuration since not all of the counters are run in the same mode with the same period.

By programming the timers directly you could synchronise them - each of the 3 counters are slightly different so its a little tricky but can be done.

Separate Arduinos have separate clock sources. Unos don’t use a crystal so can’t even get with 0.5% or each other - a dead loss unless you replace the resonator on the board with a quartz crystal.

You could invent a protocol for synchronizing them if it really matters - is there a reason to do this though? Lots of PWM switching synchronously is going to generate larger current spikes and place greater demands on the supply and decoupling and generate more EMI.

The main reason to do this was that if you use PWM to fire LEDs, clocks being out of sync can sometimes give a FLICKER effect to the eye, which is what I was trying to avoid.

Why not use something like TLC5940 for the LEDs, then its synchronized by design.

Interesting thought. I'll look in to it ! :slight_smile:

Thanks for the earlier response.

I have looked into the 5940, and it seems it gives output frequencies in multiples of 122Hz (122,244,488,976,1.9k, etc).

I assume this based on the manipulation of the TLC_GSCLK_PERIOD and TLC_PWM_PERIOD variables. For the GSCLK to be a whole number, 0,1,2,3 etc, the values I mentioned above are possible. For getting other values such as say 100Hz, 200Hz, 250Hz, etc, the equations do not work.
I am focussing on the last bit of this sheet, the 3rd and 4th to the last formulae.

Can anybody check if this is correct?

You could invent a protocol for synchronizing them if it really matters

two thoughts come up

  • one master Arduino that triggers multiple slave Arduinos?
  • or a 555 timer as pulse generator?


The Master Arduino concept was what I was hoping for. Is there a way to do this?

The Master Arduino concept was what I was hoping for. Is there a way to do this?

THe idea is as follows:

You have one Master Arduino that outputs a PWM signal, the Slave Arduinos have an interrupt routine on port 2 that follow this signal with direct port manipulation.

(not tested, just to get the idea)

void setup()
  pinMode(2, INPUT);  
  for (int pin = 7; pin < 13; pin++) pinMode(pin, OUTPUT); 

  attachInterrupt(0, myirq, CHANGE);

// this just follows the PWM, you could also use other patterns 
void myirq()
  if ((PORTD & 0x20) == 0x20) PORTB = 0xFF;
  else PORTB = 0;

void loop()