Pages: [1]   Go Down
Author Topic: Problem fading multiple delays  (Read 259 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4545
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Use "analogueWrite()" on those pins.
Logged

No, I don't answer questions sent in private messages...

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

Copenhagen, Denmark
Offline Offline
Edison Member
*
Karma: 25
Posts: 1133
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay,
This seems to be working!
Code:
#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
}

Logged

Pages: [1]   Go Up
Jump to: