Go Down

Topic: Problem fading multiple delays (Read 419 times) previous topic - next topic

Jedra

Hi everybody!
I have been looking into using various libraries; "LedFader", "SoftPWM" for instance.
I am trying to set up six pins on an Uno to crossfade six leds, each consecutively.

First led fade up
second led fade up
third led fade up while the first fades down
fourth led fade up while second fades down
fifth fade up while the third fades down
sixth fade up while the fourth fades down
fifth fades down
sixth fades down

Is it possible to add pauses into an LedFader based sketch?
I now realize what a beginner I am at this. Any advice would be appreciated
Thanks!

fungus

Arduino Unos have six PWM outputs. They're the pins with the little squiggle next to the number.

Use "analogueWrite()" on those pins.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Jedra

Thanks, Fungus.
My question is more to do with programming. I am trying to compile a sketch right now and will post it when I get stuck.
I am using  SoftPWM library...

Msquare

"stuck".? Have you been eating honey sandwiches and now everything is sticky? Or what is "stuck" and where?

Jedra

Okay,
This seems to be working!
Code: [Select]
#include <SoftPWM.h>

void setup()
{
  // Initialize
  SoftPWMBegin();

  // Create and set pins 3,5,6,9,10,and11 to 30 (15%)
  SoftPWMSet(3, 30);
  SoftPWMSet(5, 30);
  SoftPWMSet(6, 30);
  SoftPWMSet(9, 30);
  SoftPWMSet(10, 30);
  SoftPWMSet(11, 30);

  // Set fade time for pins 3,5,6,9,10,and 11 to 3 second fade-up time, and 3 second fade-down time
 
  SoftPWMSetFadeTime(3, 3000, 3000);
  SoftPWMSetFadeTime(5, 3000, 3000);
  SoftPWMSetFadeTime(6, 3000, 3000);
  SoftPWMSetFadeTime(9, 3000, 3000);
  SoftPWMSetFadeTime(10, 3000, 3000);
  SoftPWMSetFadeTime(11, 3000, 3000);
}

void loop()
{
 
  SoftPWMSetPercent(3, 100);// Turn on pin 3 - set to 100%
  delay(3000);              // wait 3 seconds
 
  SoftPWMSetPercent(5, 100);// Turn on pin 5 - set to 100%
  delay(3000);                // wait 3 seconds
 
  SoftPWMSetPercent(6, 100);// Turn on pin6 - set to 100%
  SoftPWMSetPercent(3, 15); // Turn off pin3 - set to 15%
  delay(3000);              // wait 3 seconds
 
  SoftPWMSetPercent(9, 100);// Turn on pin9 - set to 100%
  SoftPWMSetPercent(5, 15); // Turn off pin5 - set to 15%
  delay(3000);               // wait 3 seconds
 
  SoftPWMSetPercent(10, 100);// Turn on pin10 - set to 100%
  SoftPWMSetPercent(6, 15);  // Turn off pin6 - set to 15%
  delay(3000);                // wait 3 seconds
 
  SoftPWMSetPercent(11, 100);// Turn on pin11 - set to 100%
  SoftPWMSetPercent(9, 15);  // Turn off pin9 - set to 15%
  delay(3000);                 // wait 3 seconds
 
  SoftPWMSetPercent(10, 15); // Turn off pin10 - set to 15%
  delay(3000);                  // wait 3 seconds
 
  SoftPWMSetPercent(11, 15); // Turn off pin11 - set to 15%
 
  delay(3000);                  // wait 3 seconds
}



Go Up