Fading multiple groups of LEDs in sequence, & PIR triggered fade

I am relatively new to programming the Arduino, but here is what I need to do:

Project 1) I am working with 5 groups of 12volt LED modules. I need to fade each group in, then out, in sequence: one group after another. I have a Darlington transistor circuit for each group to convert PWM from the Arduino.

Project 2) I need a group of LEDs, also connected to a Darlington transistor circuit, to fade in when a PIR sensor is HIGH, stay on as long as the PIR sensor is HIGH, then fade the LEDs out when the PIR sensor is LOW.

With my limited experience I can program a simple on/off but am having great difficulty with the fading. Any help would be appreciated! Thanks.

Aren't there some fade examples in the IDE?
Have you tried any?

Yes, I have looked at several but haven't found any that work for 1) fading groups in sequence or 2) fading LEDs on in response to a PIR sensor, staying on until the PIR sensor goes LOW and then fading off.

Does anyone have any suggestions?
Thanks.

markart:
Yes, I have looked at several but haven't found any that work for 1) fading groups in sequence or 2) fading LEDs on in response to a PIR sensor, staying on until the PIR sensor goes LOW and then fading off.

Does anyone have any suggestions?
Thanks.

Yes; post the code you've already tried, along with your observations and expectations.

Thanks. Here's a good example of what I am running into and because of my inexperience don't know what to do. The attached code works great to fade a single group of LEDs in and out. But:

  1. Because this code has to loop to change the brightness I don't know how to modify it to fade several groups in & out in sequence or even if it is possible.
  2. Can this code be used to respond to a PIR motion sensor: fading on and staying on when HIGH, then fading off when LOW?

I'd appreciate any suggestions. Thanks for your help.

___sketch_apr23a.ino (951 Bytes)

Here's the code text:

/*
Fade

This example shows how to fade an LED on pin 9
using the analogWrite() function.

This example code is in the public domain.
*/

int led = 9; // the pin that the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by

// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 9:
analogWrite(led, brightness);

// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;

// reverse the direction of the fading at the ends of the fade:
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}

When posting code use code tags please.

Take that fading code and create a function with it. The only thing you need to do is to change the pin 9 analogWrite into an analogue write that uses a pin number passes to the function.
Then in the loop function call this new function you have written passing it the value 9, and then again as many times as you want passing it diffrent pin numbers to fade.

You will probbly have to look up things like how to make a function and pass variables to it but it is all part of the process of learning how to program.

Thanks, I appreciate the help. I'll try this.