i need to get 50 Hz on 4 pwm pins so that i can use simple commands to change duty cycle between my desired range that is 1ms to 2ms to control speed of 4 brushless dc motors,i used the following library to get 50Hz on my desired pwm pins
http://forum.arduino.cc/index.php?topic=117425.0, and it works fine except that now code doesn't seem to enter in the for loop to change dutycyle between my desired range . if i write pwmWrite command outside loop by giving only one brightness value (duty cycle) then it works fine.
here is my code.
#include <PWM.h>
int32_t frequency = 50; //frequency (in Hz)
void setup()
{
//initialize all timers except for 0, to save time keeping functions
InitTimers();
//sets the frequency for the specified pin
SetPinFrequency(3, frequency);
SetPinFrequency(5, frequency);
SetPinFrequency(9, frequency);
SetPinFrequency(10, frequency);
}
void loop()
{
for (int brightness=13; brightness<=26; brightness++)
{
pwmWrite(3, brightness);
pwmWrite(5, brightness);
pwmWrite(9, brightness);
pwmWrite(10, brightness);
delay(30);
}
for (int brightness=26; brightness>=13; brightness--)
{
pwmWrite(3, brightness);
pwmWrite(5, brightness);
pwmWrite(9, brightness);
pwmWrite(10, brightness);
delay(30);
}
}