Go Down

Topic: sending pwm to multiple pins using CurrieTimerOne.pwmStart (Read 463 times) previous topic - next topic


I'm trying to use the CurrieTimerOne.pwmStart command to send clock signals to multiple pins, but I'm only able to use this function for one pin at a time.  Whichever pin is listed last will work, while the first one is just high.  Is there a way to use this function for multiple pins with different clock speeds?

Code: [Select]
#include "CurieTimerOne.h"

void setup() {

// CurieTimer PWM function - pin, dutycyle(0-1023), period(us)

CurieTimerOne.pwmStart(4, 512, 1000);    // SHCP Serial Clock on PIN 4 - 1ms 1kHz
CurieTimerOne.pwmStart(13, 512, 100000);  // blink LED on PIN 13 - 100ms 10Hz



Hi Zonan,

pwmStart() function simply wraps a callback to a PWM-like function (see https://github.com/01org/corelibs-arduino101/blob/master/libraries/CurieTimerOne/src/CurieTimerOne.cpp#L190), so calling more than once overrides the previous setup.

To overcome this, you can copy pwmCallback function inside the sketch (https://github.com/01org/corelibs-arduino101/blob/master/libraries/CurieTimerOne/src/CurieTimerOne.cpp#L208), adapt it to your needs, then start the timer with start(period, yourCallback)

Hope it helps!


thank you sir, that's a perfect example of what I'm looking for

Go Up