Need help with code

OK so I will admit it I am totally new to this and code is not a strong point by any means.. I have my circuits figured out and on a bread board but have no clue where to start on writing the code to make it work.

Building a project and have 5 clear led's and one red the idea is that the 5 leds fade in sequence so as one fades the next comes on to give the impression of rotation. the red needs to fade in and out slow like a beacon on top of a tower or something like that.

Using a uno board. at the moment I have the red led to pin 3 and the remaining clear to pins 5,6,9,10,11 Looking for help or a master mind that can get me going.. Have been looking for already made but have not found any to this point. Watched many video but again code is not my strong point by any means..

Thank you in advance for any help

Sounds like you need a millis() based approach. Each led is basically its own 'task'. Have a look at

Using millis() for timing. A beginners guide
Demonstration code for several things at the same time

You obviously need to use PWM to fade as your demonstrate knowing in specifying the 6 pins that support it. In addition to the advice given regarding millis(), look-up 'Arduino PWM Secrets' for a good discussion on how that works. Once you've digest all that, say 5 or 10 minutes, craft a bit of code for testing. Come back, post you code and we can work from there.

Hi,
This is my take.

unsigned long currentMillis;

unsigned long redPrevMillis;
unsigned long otherPrevMillis;

const long redLedFadeDuration = 2000;
const long otherLedFadeDuration =  1000;

int currentOtherLedIndex = 0;
int redFadeCurrentValue = 250;
int otherFadeCurrentValue = redFadeCurrentValue;

const int redFadeDiff = 10;
const int otherFadeDiff = 30;

int pwmPins[] = {5,6,9,10,11};

void setup() {
//Setup all the pins

redPrevMillis = millis();
otherPrevMillis = redPrevMillis;
}

void loop() {
  currentMillis = millis();
  
  if(currentMillis - redPrevMillis >= redLedFadeDuration){
    redPrevMillis = currentMillis;
    fadeRedLed();
  }

  if(currentMillis - otherPrevMillis >= otherLedFadeDuration){
    otherPrevMillis = currentMillis;
    fadeOtherLeds();
  }
}

void fadeRedLed(){
  //this function is used to fade red
  redFadeCurrentValue = redFadeCurrentValue - redFadeDiff;
  fadeInandOutForRed();
}

void fadeOtherLeds(){
   int currentPin;
   otherFadeCurrentValue = otherFadeCurrentValue - otherFadeDiff;
   if (otherFadeCurrentValue <= 40){
    currentOtherLedIndex = currentOtherLedIndex + 1; //go to other pin
    otherFadeCurrentValue = 250;
    //if reached last led ,reset all other pins ans set index to zero
    if(currentOtherLedIndex > sizeof(pwmPins) - 1){
      resetAllOtherPins();
      currentOtherLedIndex = 0;
    }//end of if
   }//end of if
   currentPin = pwmPins[currentOtherLedIndex];
   analogWrite(currentPin,otherFadeCurrentValue);
}

//reset all other pins i.e write 255 to all pins
void resetAllOtherPins(){
  
}

//simple fadeIn And Out Algorithm for Red led
void fadeInandOutForRed(){
  
}

The code compiles but didn’t tested. Fill the missing bits.
any modifications/suggestions are welcome.

Are you anilkunchalaece or aarley?

OK so I used one of the pre written code templates and have gotten started but seems to be doing opposite of what I want it to do they are all staying on then fading off, the idea is to have them off and then fade on and off, then I need to incorporate the final fade or blink of a red led. So here is what I have started 1st the Clear led fade off to on to off is what I need, Leds are plugged into same pins listed:

*/

int led_5 = 5; // the PWM pin the LED is attached to
int led_6 = 6; // the PWM pin the LED is attached to
int led_9 = 9; // the PWM pin the LED is attached to
int led_10 = 10; // the PWM pin the LED is attached to
int led_11 = 11; // the PWM pin the LED is attached to

int brightness_5 = 0; // how bright the LED is
int brightness_6 = 100; // how bright the LED is
int brightness_9 = 200; // how bright the LED is
int brightness_10 = 400; // how bright the LED is
int brightness_11 = 500; // how bright the LED is

int fadeAmount_5 = 5; // how many points to fade the LED by
int fadeAmount_6 = 5; // how many points to fade the LED by
int fadeAmount_9 = 5; // how many points to fade the LED by
int fadeAmount_10 = 5; // how many points to fade the LED by
int fadeAmount_11 = 5; // how many points to fade the LED by

// the setup routine runs once when you press reset:
void setup() {
// declare pin 5 to be an output:
// declare pin 6 to be an output:
// declare pin 9 to be an output:
// declare pin 10 to be an output:
// declare pin 11 to be an output:

pinMode(led_5, OUTPUT);
pinMode(led_6, OUTPUT);
pinMode(led_9, OUTPUT);
pinMode(led_10, OUTPUT);
pinMode(led_11, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {

// set the brightness of pins individually:
analogWrite(led_5, brightness_5);
analogWrite(led_6, brightness_6);
analogWrite(led_9, brightness_9);
analogWrite(led_10, brightness_10);
analogWrite(led_11, brightness_11);

// change the brightness for next time through the loop:
brightness_5 = brightness_5 + fadeAmount_5;
brightness_6 = brightness_6 + fadeAmount_6;
brightness_9 = brightness_9 + fadeAmount_9;
brightness_10 = brightness_10 + fadeAmount_10;
brightness_11 = brightness_11 + fadeAmount_11;

// reverse the direction of the fading at the ends of the fade:
if (brightness_5 <= 0 || brightness_5 >= 255) {
fadeAmount_5 = -fadeAmount_5;
}else if (brightness_6 <= 0 || brightness_6 >= 255) {
fadeAmount_6 = -fadeAmount_6;
}else if (brightness_9 <= 0 || brightness_9 >= 255) {
fadeAmount_9 = -fadeAmount_9;
}else if (brightness_10 <= 0 || brightness_10 >= 255) {
fadeAmount_10 = -fadeAmount_10;
}else if (brightness_11 <= 0 || brightness_11 >= 255) {
fadeAmount_11 = -fadeAmount_11;
}

// wait for 30 milliseconds to see the dimming effect
delay(30);
}

Then for the red led I am trying to get it slower and off longer on is good… then I need to figure how to combine the two different codes to make one for it all to work together:

*/

int led = 3; // the PWM pin 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 3 to be an output:
pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 3:
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);
}

Hope fully someone has the answer.

Please edit your post to add code tags ("</>" button).