#include "SoftwarePWM.h"
int dir;
int dutyCycle;
unsigned long timer;
uint8_t pins [10] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
SoftwarePWM swPWM(pins, 10);
void setup(){
for (int i = 0; i < 10; ++i) {
swPWM.setFrequency(i, 500);
}
}
void loop()
{
unsigned long now = millis();
if (now - timer > 10)
{
for (int i = 0; i < 10; ++i)
{
if (dir == 1)
{
if (dutyCycle < 255)
{
dutyCycle++;
}
else
{
dir = 0;
}
}
else
{
if (dutyCycle > 0)
{
dutyCycle--;
}
else
{
dir = 1;
}
}
swPWM.setDutyCycle(i, dutyCycle);
}
timer = now;
}
swPWM.refresh();
}