RGB LEDS Strip Help!

Hello,
I have created code for two sets of LED strips called ledUPPER and ledLOWER. They will be controlled from Pins 9 and 10 respectively.
I am having trouble writing dual code for both LED strips (I think my code is messy) and not functioning how I would like it to work. For instance;
Function 'Pulse' should create an LED pulse going UP and DOWN the LED strip, with direction showing which way it should go
Function 'Stripe' just makes a stripe of less go up and down quickly in different colours.

My problem is, I believe the two different LED strips are causing issues with each other as the programme does not function correctly.
Also my code for 'Stripe' looks like it could be reduced to a better (shorter) loop

Could anyone help me with separating the two LED strips in the code????
If you keep it all in one file, the main code is RGB_EX1.ino

Many thanks, David

RGB_EX1.ino (3.2 KB)

Broadway.ino (2.21 KB)

Pulse.ino (3.27 KB)

Stripe.ino (4.85 KB)

Hi, please post your sketches as replies using code tags. Not everyone can easilly view them as attachments like that. Thanks.

Paul

//RGB Sign
#include "FastLED.h"
// Arduino Pins
#define DataPINALS (3, OUTPUT);        // Arduino Port 3, ALSAGER
#define DataPINCOMP (4, OUTPUT);       // Arduino Port 4, COMPUTERS
#define DATAPINRPLE (5, OUTPUT);       // Arduino Port 5, Repairs, PCs. Laptops and Electronics
#define DataPINUPPER 9                 // Arduino Port 9, Upper Row of LEDs
#define DataPINLOWER 10                // Arduino Port 10, Lower Row of LEDs
#define NUM_LEDSUPPER (17)             // Amount of LEDs in Strip?
#define NUM_LEDSLOWER (11)             // Amount of LEDs in Strip?

int ledPosUPPER = 0;
int ledPosLOWER = 0;
//Strip Direction
boolean dirU = 0;        //used to assess direction of strip
boolean dirL = 0;        //used to assess direction of strip 

int foo = 0;         //used in the delay

int pause = 30;        //used to make pauses's easier
unsigned long time = 0;  //used in counting time passed
unsigned long timeP = 0;  //used in counting time passed

CRGB ledsUPPER[NUM_LEDSUPPER];
CRGB ledsLOWER[NUM_LEDSLOWER]; // Defines 2nd array    
     
     
     
                                                 
void setup() {
  Serial.begin(9600);
  //Defining the Arrays
  FastLED.addLeds<NEOPIXEL, DataPINUPPER>(ledsUPPER, NUM_LEDSUPPER);    //set the RGB Strip as output for Upper LEDs
  FastLED.addLeds<NEOPIXEL, DataPINLOWER>(ledsLOWER, NUM_LEDSLOWER);    //set the RGB Strip as output for Lower LEDs
  
}




void loop () {
  
  time = millis() - timeP; // Store current time and subtract previous time value
  
  if (time <= 10000) {
    Pulse();
    
  }
  if (time > 10000 && time <= 20000) {
    Stripe();
    
  }
  if (time >=20000) {
    timeP -= time;
    
  }
}    
 
  void Pulse() {
 /*
Pulses along the RGB line and back
   */        
analogWrite (3, 150);
analogWrite (4, 150);
analogWrite (5, 150);
    
    byte reds[5] = { 250, 150, 75, 25, 0 };  // Last one goes black because of RGB 0,0,0. 
    byte grns[5] = { 0, 0, 0, 0, 0 };
    byte blus[5] = { 0, 0, 0, 0, 0 };
    byte reds2[5] = { 0, 0, 0, 0, 0 };
    byte blus2[5] = { 250, 150, 75, 25, 0 };
    
  ledsUPPER[ledPosUPPER].setRGB(255, 0, 0);     //set LED on and colour for Pos, this sets the main colour in both directions
  ledsLOWER[ledPosLOWER].setRGB(0, 0, 255);     //set LED on and colour for Pos, this sets the main colour in both directions  
   //leds[ledPos] = CRGB::HotPink;              //alternative method of lighting RGBs
    for(byte i=0; i<5; i++){
        if(ledPosUPPER - i > 0 && dirU == 0) ledsUPPER[ledPosUPPER -i - 1].setRGB(reds[i], grns[i], blus[i]);
        else{
         if(ledPosUPPER + i > 0 && dirU == 1) ledsUPPER[ledPosUPPER +i + 1].setRGB(reds[i], grns[i], blus[i]); 
         }
    }
    
    for(byte p=0; p<5; p++){
        if(ledPosLOWER - p > 0 && dirL == 0) ledsLOWER[ledPosLOWER -p - 1].setRGB(reds2[p], grns[p], blus2[p]);
        else{
         if(ledPosLOWER + p > 0 && dirL == 1) ledsLOWER[ledPosLOWER +p + 1].setRGB(reds2[p], grns[p], blus2[p]); 
          }    
     }
     
    FastLED.show();      // Set the LEDs on

    delay (pause);
    if (dirU == 0) {
      ledPosUPPER++;      //If the LED is equal to Zero, add one on next time 
    }
    if (dirL == 0){
      ledPosLOWER++;     //If the LED is equal to Zero, add one on next time 
    }
    
    if (dirU == 1) ledPosUPPER--;                         //If the LED is above or equal to NUM_LEDS-1, decrease one next time.
    if (dirL == 1) ledPosLOWER--;                         //If the LED is above or equal to NUM_LEDS-1, decrease one next time.
    if (ledPosUPPER >= NUM_LEDSUPPER-1) dirU = 1;         //Defines RGB strip going back
    if (ledPosLOWER >= NUM_LEDSLOWER-1) dirL = 1;         //Defines RGB strip going back
    if (ledPosUPPER <= 0) dirU = 0;                       //Defines RGB strip going forward
    if (ledPosLOWER <= 0) dirL = 0;                       //Defines RGB strip going forward
    delay(pause);
}
 
 
void Stripe(){
      /*
A Stripe of Colour that goes up and then down, in multiple colours
 */
int white[3]  = { 100, 100, 100 };
int red[3]    = { 100, 0, 0 };
int green[3]  = { 0, 100, 0 };
int blue[3]   = { 0, 0, 100 };
int yellow[3] = { 40, 95, 0 };
   
  
   	// First slide the led in one direction
	for(int i = 0; i < NUM_LEDSUPPER; i++) {
		// Set the i'th led to red 
		ledsUPPER[i] = CRGB::Green;
		// Show the leds
		FastLED.show();
		// now that we've shown the leds, reset the i'th led to black
		//leds[i] = CRGB::Black;
		// Wait a little bit before we loop around and do it again
		delay(pause);
	}
	// Now go in the other direction.  
	for(int i = NUM_LEDSUPPER-1; i >= 0; i--) {
		// Set the i'th led to red 
		ledsUPPER[i] = CRGB::Green;
		// Show the leds
		FastLED.show();
		// now that we've shown the leds, reset the i'th led to black
		ledsUPPER[i] = CRGB::Black;
		// Wait a little bit before we loop around and do it again
		delay(pause);
        }
        /*
	for(int i = 0; i < NUM_LEDSUPPER; i++) {
		// Set the i'th led to red 
		ledsUPPER[i] = CRGB::Red;
		// Show the leds
		FastLED.show();
		// now that we've shown the leds, reset the i'th led to black
		//leds[i] = CRGB::Black;
		// Wait a little bit before we loop around and do it again
		delay(pause);
        }
         // Now go in the other direction.  
	for(int i = NUM_LEDSUPPER-1; i >= 0; i--) {
		// Set the i'th led to red 
		ledsUPPER[i] = CRGB::Red;
		// Show the leds
		FastLED.show();
		// now that we've shown the leds, reset the i'th led to black
		ledsUPPER[i] = CRGB::Black;
		// Wait a little bit before we loop around and do it again
		delay(pause);
	}
        for(int i = 0; i < NUM_LEDSUPPER; i++) {
		// Set the i'th led to red 
		ledsUPPER[i] = CRGB::Blue;
		// Show the leds
		FastLED.show();
		// now that we've shown the leds, reset the i'th led to black
		//leds[i] = CRGB::Black;
		// Wait a little bit before we loop around and do it again
		delay(pause);}
         // Now go in the other direction.  
	for(int i = NUM_LEDSUPPER-1; i >= 0; i--) {
		// Set the i'th led to red 
		ledsUPPER[i] = CRGB::Blue;
		// Show the leds
		FastLED.show();
		// now that we've shown the leds, reset the i'th led to black
		ledsUPPER[i] = CRGB::Black;
		// Wait a little bit before we loop around and do it again
		delay(pause);}
    for(int i = 0; i < NUM_LEDSUPPER; i++) {
		// Set the i'th led to red 
		ledsUPPER[i] = CRGB::Purple;
		// Show the leds
		FastLED.show();
		// now that we've shown the leds, reset the i'th led to black
		//leds[i] = CRGB::Black;
		// Wait a little bit before we loop around and do it again
		delay(pause);}
         // Now go in the other direction.  
	for(int i = NUM_LEDSUPPER-1; i >= 0; i--) {
		// Set the i'th led to red 
		ledsUPPER[i] = CRGB::Purple;
		// Show the leds
		FastLED.show();
		// now that we've shown the leds, reset the i'th led to black
		ledsUPPER[i] = CRGB::Black;
		// Wait a little bit before we loop around and do it again
		delay(pause);}
    for(int i = 0; i < NUM_LEDSUPPER; i++) {
		// Set the i'th led to red 
		ledsUPPER[i] = CRGB::Yellow;
		// Show the leds
		FastLED.show();
		// now that we've shown the leds, reset the i'th led to black
		//leds[i] = CRGB::Black;
		// Wait a little bit before we loop around and do it again
		delay(pause);}

         // Now go in the other direction.  
	for(int i = NUM_LEDSUPPER-1; i >= 0; i--) {
		// Set the i'th led to red 
		ledsUPPER[i] = CRGB::Yellow;
		// Show the leds
		FastLED.show();
		// now that we've shown the leds, reset the i'th led to black
		ledsUPPER[i] = CRGB::Black;
		// Wait a little bit before we loop around and do it again
		delay(pause);
        }
        */
}