I am working on a code to drive LEDs at pins 3, 9 and 10. The pulsed signal has to be in the range of 10-100 Hz.
Using pwm.h library, I output,for eg. 40 Hz signal.
As I understood, 9 and 10 automatically share the same frequency and I see the same in the oscilloscope. Also, I get the same frequency on pin 3. However, it is not in sync to the remaining two signals.
What I really want is that the waveforms coincide, so that each LED lights up at the same time.
Can someone point what I'm missing?
Following is the code.
#include <PWM.h>
int32_t frequency = 40; //frequency (in Hz)
void setup()
{InitTimersSafe();
SetPinFrequencySafe(9, frequency);
SetPinFrequencySafe(3, frequency);
SetPinFrequencySafe(10, frequency);}
void loop()
{pwmWrite(9, HIGH);
pwmWrite(3, HIGH);
pwmWrite(10, HIGH);
delayMicroseconds(1110);
pwmWrite(9, LOW);
pwmWrite(3, LOW);
pwmWrite(10, LOW);
delayMicroseconds(2220);}