My loop only runs once. Need help with my functions.

I have written a sketch to blink and dazzle 5 RGB LEDs. My sketch runs one time through and when it gets back to the first function named " RED()" it seems to hang in that function. The LEDs are cycling but, it does not move to the next function for a couple minutes. When it does the LEDs are flickering badly. I want my loop to cycle over and over. Later I will add a control system to select my functions individually.

I think my problem is the way I am using my functions, can someone help please?

I am using USB power and 220ohm resistors on each LED color PIN.

//const int ledpin1 = 3;//LED 1 RED
//const int ledpin2 = 5;//LED 1 GREEN
//const int ledpin3 = 6;//LED 1 BLUE

//const int ledpin4 = 9;//LED 2 RED
//const int ledpin5 = 10;//LED 2 GREEN
//const int ledpin6 = 11;//LED 2 BLUE

//const int ledpin7 = 12;//LED 3 RED
//const int ledpin8 = 13;//LED 3 GREEN
//const int ledpin9 = 7;//LED 3 BLUE

//const int ledpin10 = 14;//LED 4 RED
//const int ledpin11 = 15;//LED 4 GREEN
//const int ledpin12 = 16;//LED 4 BLUE

//const int ledpin13 = 17;// LED 5 RED
//const int ledpin14 = 18; // LED 5 GREEN
//const int ledpin15 = 19; // LED 5 BLUE

#include <SoftPWM.h>

const int ledPins[] = {
  3, 5, 6, 9, 10, 11, 12, 13, 7, 14, 15, 16, 17, 18, 19};       // an array of pin numbers to which LEDs are attached

const int pinCount = 15;           // the number of pins (i.e. the length of the array)

int thisPin ;

const int REDPins[] = {
  3, 9, 12, 14, 17};

const int GREENPins[] = {
  5, 10, 13, 15, 18};

const int BLUEPins[] = {
  6, 11, 7, 16, 19};

const int colorPins = 5;

// LED leads connected to PWM pins
const int RED_LED_PIN = 3;
const int GREEN_LED_PIN = 5;
const int BLUE_LED_PIN = 6;
const int RED_LED_PIN2 = 9;
const int GREEN_LED_PIN2 = 10;
const int BLUE_LED_PIN2 = 11;

// Used to store the current intensity level of the individual LEDs
int redIntensity = 0;
int greenIntensity = 0;
int blueIntensity = 0;

// Length of time we spend showing each color
const int DISPLAY_TIME = 55; // In milliseconds
const int ON_TIME = 1000;//TIME ON FOR FLASHES
const int OFF_TIME = 50; // TIME ON FOR FLASHES In milliseconds
const int repeats = 9000;// how many times to reapeat color loops

void All(){
  for (int i = 0; i < repeats; i++){ 
    for (thisPin = 0 ; thisPin < pinCount ; thisPin++)  {
      digitalWrite(ledPins[thisPin],HIGH);
      digitalWrite(ledPins[thisPin],LOW);
    }
  }
    return; 
}


void RED(){
  for (int i = 0; i <repeats; i++){ 
    for (thisPin = 0 ; thisPin < colorPins ; thisPin++)  {
      digitalWrite(REDPins[thisPin],HIGH);
      digitalWrite(REDPins[thisPin],LOW);
    }
     }
     
  return;
}

void GREEN(){
  for (int i = 0; i < repeats; i++){
    for (thisPin = 0 ; thisPin < colorPins ; thisPin++)  {
      digitalWrite(GREENPins[thisPin],HIGH);
      digitalWrite(GREENPins[thisPin],LOW);
    }
      }
      
  return; 
}

void BLUE(){
  for (int i = 0; i < repeats; i++){
    for (thisPin = 0 ; thisPin < colorPins ; thisPin++)  {
      digitalWrite(BLUEPins[thisPin],HIGH);
      digitalWrite(BLUEPins[thisPin],LOW);
    }
     }
     
  return; 
}

void AQUA(){
  for (int i = 0; i < repeats; i++){
    for (thisPin = 0 ; thisPin < colorPins ; thisPin++)  {
      digitalWrite(BLUEPins[thisPin],HIGH);
      digitalWrite(GREENPins[thisPin],HIGH);
      digitalWrite(BLUEPins[thisPin],LOW);
      digitalWrite(GREENPins[thisPin],LOW);
    }
     }
     
  return; 
}

void PURPLE(){
  for (int i = 0; i < repeats; i++){
    for (thisPin = 0 ; thisPin < colorPins ; thisPin++)  {
      digitalWrite(BLUEPins[thisPin],HIGH);
      digitalWrite(REDPins[thisPin],HIGH);
      digitalWrite(BLUEPins[thisPin],LOW);
      digitalWrite(REDPins[thisPin],LOW);
    }
  }
  
  return; 
}

void BROWN(){
  for (int i = 0; i < repeats; i++){ 
    for (thisPin = 0 ; thisPin < colorPins ; thisPin++)  {
      digitalWrite(GREENPins[thisPin],HIGH);
      digitalWrite(REDPins[thisPin],HIGH);
      digitalWrite(GREENPins[thisPin],LOW);
      digitalWrite(REDPins[thisPin],LOW);
    }
  }
  
  return; 
}

void fadetry(){

  return;
}

void flashall(){
  for (thisPin = 0 ; thisPin < pinCount ; thisPin++)  {
    for (int i = 0; i < 2; i++){     
      digitalWrite(ledPins[thisPin], HIGH);
      delay(ON_TIME);
      digitalWrite(ledPins[thisPin],LOW);
      delay(OFF_TIME);
    }
  }
  
  return; 
}

void flash_RED(){
  for (thisPin = 0 ; thisPin < colorPins; thisPin++)  {
    for (int i = 0; i < 2; i++){     
      digitalWrite(REDPins[thisPin], HIGH);
      delay(ON_TIME);
      digitalWrite(REDPins[thisPin],LOW);
      delay(OFF_TIME);
    }
  }
  
  
}

void flash_GREEN(){
  for (thisPin = 0 ; thisPin < colorPins; thisPin++)  {
    for (int i = 0; i < 2; i++){     
      digitalWrite(GREENPins[thisPin], HIGH);
      delay(ON_TIME);
      digitalWrite(GREENPins[thisPin],LOW);
      delay(OFF_TIME);
    }
  }
  
  return; 
}

void flash_PURPLE(){
  for (thisPin = 0 ; thisPin < colorPins; thisPin++)  {
    for (int i = 0; i < 2; i++){     
      digitalWrite(BLUEPins[thisPin], HIGH);
      digitalWrite(REDPins[thisPin], HIGH);
      delay(ON_TIME);
      digitalWrite(BLUEPins[thisPin],LOW);
      digitalWrite(REDPins[thisPin],LOW);
      delay(OFF_TIME);
    }
  }
  
  return; 
}

void flash_AQUA(){
  for (thisPin = 0 ; thisPin < colorPins; thisPin++)  {
    for (int i = 0; i < 2; i++){     
      digitalWrite(BLUEPins[thisPin], HIGH);
      digitalWrite(GREENPins[thisPin], HIGH);
      delay(ON_TIME);
      digitalWrite(BLUEPins[thisPin],LOW);
      digitalWrite(GREENPins[thisPin],LOW);
      delay(OFF_TIME);
    }
  }
  
  return; 
}

void flash_BLUE(){
  for (thisPin = 0 ; thisPin < colorPins; thisPin++)  {
    for (int i = 0; i < 2; i++){     
      digitalWrite(BLUEPins[thisPin], HIGH);
      delay(ON_TIME);
      digitalWrite(BLUEPins[thisPin],LOW);
      delay(OFF_TIME);
    }
  }
  
  return; 
}

void RED_GREEN(){
  // Cycle color from red through to green
  // (In this loop we move from 100% red, 0% green to 0% red, 100% green)
  for (greenIntensity = 0; greenIntensity <= 255; greenIntensity+=5) {
    redIntensity = 255-greenIntensity;
    analogWrite(GREEN_LED_PIN, greenIntensity);
    analogWrite(GREEN_LED_PIN2, greenIntensity);
    analogWrite(RED_LED_PIN, redIntensity);
    analogWrite(RED_LED_PIN2, redIntensity);
    delay(DISPLAY_TIME);
  }
  return; 
}

void GREEN_BLUE(){
  // Cycle color from green through to blue
  // (In this loop we move from 100% green, 0% blue to 0% green, 100% blue) 
  for (blueIntensity = 0; blueIntensity <= 255; blueIntensity +=5){
    greenIntensity = 255-blueIntensity;
    analogWrite(BLUE_LED_PIN, blueIntensity);
    analogWrite(BLUE_LED_PIN2, blueIntensity);
    analogWrite(GREEN_LED_PIN, greenIntensity);
    analogWrite(GREEN_LED_PIN2, greenIntensity);
    delay(DISPLAY_TIME);
  }
  return; 
}

void BLUE_RED(){
  // Cycle cycle from blue through to red
  // (In this loop we move from 100% blue, 0% red to 0% blue, 100% red)   
  for (redIntensity = 0; redIntensity <= 255; redIntensity+=5){
    blueIntensity = 255-redIntensity;
    analogWrite(RED_LED_PIN, redIntensity);
    analogWrite(RED_LED_PIN2, redIntensity);
    analogWrite(BLUE_LED_PIN, blueIntensity);
    analogWrite(BLUE_LED_PIN2, blueIntensity);
    delay(DISPLAY_TIME);
  }
  return; 
}

void FADE_IN_OUT(){
  for (thisPin = 0 ; thisPin < pinCount ; thisPin++)  {
    SoftPWMSet(ledPins[thisPin],255);
    delay(170);
    SoftPWMSet(ledPins[thisPin],0);
    delay(150);
  }
  return; 
}

void setup()
{
  SoftPWMBegin() ;   
  // use a for loop to initialize each pin as an output:
  for (thisPin = 0 ; thisPin < pinCount ; thisPin++)  {
    SoftPWMSet(ledPins[thisPin], 0);  
    SoftPWMSetFadeTime(ledPins[thisPin], 1000, 1000);    
  }
}


void loop()
{
  RED();
  PURPLE();
  BLUE();
  All();
  AQUA();
  GREEN();
  BROWN();
  RED_GREEN();
  GREEN_BLUE();
  BLUE_RED();
  flashall();
  flash_RED(); 
  flash_PURPLE();
  flash_AQUA();
  flash_BLUE();
  flash_GREEN();
  FADE_IN_OUT();



}

Do you have a ULN2803? I think you are overloading the +5V regulator, and Software PWM is blocking, meaning until it has finished its business execution does not return to your code. The hardware PWM uses hardware interrupts and dedicated timer hardware making it possible for it run in the background. analogWrite is one of these hardware PWM commands, Comment out the fade out in call in void(). With a voltmeter monitor the +5V terminal if it is dropping you will have to buffer the led's and supply from another source.

void RED(){
  for (int i = 0; i <repeats; i++){ 
    for (thisPin = 0 ; thisPin < colorPins ; thisPin++)  {
      digitalWrite(REDPins[thisPin],HIGH);
      digitalWrite(REDPins[thisPin],LOW);
    }
     }
     
  return;
}

What’s supposed to be going on here? You seem to be turning all the pins HIGH and immediately LOW 9000 times. Is this the method you’re using to control the timing of your sketch? It does not strike me as a good technique. If you want it to delay for a fixed time, put a delay in. (If you want your sketch to be able to do other things in the meantime, use the ‘blink without delay’ techniques to keep your sketch running while you wait for the time to pass.

PeterH:

void RED(){

for (int i = 0; i <repeats; i++){
    for (thisPin = 0 ; thisPin < colorPins ; thisPin++)  {
      digitalWrite(REDPins[thisPin],HIGH);
      digitalWrite(REDPins[thisPin],LOW);
    }
     }
     
  return;
}




What's supposed to be going on here? You seem to be turning all the pins HIGH and immediately LOW 9000 times. Is this the method you're using to control the timing of your sketch? It does not strike me as a good technique. If you want it to delay for a fixed time, put a delay in. (If you want your sketch to be able to do other things in the meantime, use the 'blink without delay' techniques to keep your sketch running while you wait for the time to pass.

I am doing it that way to make it look like all 5 of the LEDs are lit at the same time. The 9000 times make them glow for a second or two. I am only lighting one pin at a time do it that way.

I will try the comment out suggestion and see what happens.

Thanks

@ajofscott, I checked voltage and it never shows below 4.9v. I then used a 12v wall plug and my sketch still hangs when it returns to the first function. Commenting out functions did help but, fade-in-out does not seem to be the problem. I still need to run the sketch more to see what combination is the final straw.

@PeterH, I had to think a while about what you said and I realized that my repeat method is blocking and I could use "blink without delay" technique to time my events. I will need to keep my other functions from running at the same time. I could possible add some "if" conditionals.

Thanks for the replies so far. I plan to keep testing and building the led dazzle code and share the results. :)

I am still having trouble with this sketch. I have commented all of the return; statements in the functions but, it has not helped. The Arduino seems to run threw all of the functions one time and then gets hung in the first for loop "void RED()". I have tried this with 2 different Arduinos. I am thinking it is a ram issue but, I don't know the answer.

Any ideas how on how to fix this?

void BLUE(){
  for (int i = 0; i < repeats; i++){
    for (thisPin = 0 ; thisPin < colorPins ; thisPin++)  {
      digitalWrite(BLUEPins[thisPin],HIGH);
      digitalWrite(BLUEPins[thisPin],LOW);
    }
     }
     
  return; 
}

Why the “return”?
Don’t you trust the compiler?

Why the "return"? Don't you trust the compiler?

I guess now that you mention it, if you return nothing, it is the same as not putting a "return;"???

One part of this exercise was for me to learn how to write and use functions. I have tried commenting out all of the return; statements but, it did not help.

Put some debugging prints in there - how do you know where it's getting 'stuck'?

Why is thisPin a global variable? Why is the loop index not defined in the for statement as a local variable, with the typical one letter name?

  for (int i = 0; i < repeats; i++)
  {
    for (int j = 0 ; j < colorPins ; j++)
    {
      digitalWrite(BLUEPins[j],HIGH);
      digitalWrite(BLUEPins[j],LOW);
    }
  }

What is the purpose of turning the set of pins on and off as fast as possible some number of times? With no delay() in there, the whole loop will execute very quickly, apparently accomplishing nothing.

wildbill:
Put some debugging prints in there - how do you know where it’s getting ‘stuck’?

My loop starts with running the void RED() function with the red LEDs lit… It goes threw all of the functions 1 time and when it gets back to RED the LEDs cycle like it is running the RED function endlessly. Sometimes, after a minute, it will move to the next function but, freeze on it. So, basically the LEDs are my debugging method. I suppose I would not hurt to put a few prints in the sketch and see if it helps.

Insert Quote
Why is thisPin a global variable? Why is the loop index not defined in the for statement as a local variable, with the typical one letter name?
repeats and colorPins are defined as global so that I can change them in the defines or later in the loop.

Code:

for (int i = 0; i < repeats; i++)
{
for (int j = 0 ; j < colorPins ; j++)
{
digitalWrite(BLUEPins[j],HIGH);
digitalWrite(BLUEPins[j],LOW);
}
}

What is the purpose of turning the set of pins on and off as fast as possible some number of times? With no delay() in there, the whole loop will execute very quickly, apparently accomplishing nothing.

It was my solution to firing the LEDs to make them look like they are on all of the time. I am aware that it is blocking and I will need to change the sketch somehow to solve that. I hope to get this base sketch to work and then later, use a IR remote control to select functions on the fly.

I think the only way to keep led "blinking" that way while other code executes is to use hw pwm, which is a sort of parallel "processor" (well, periferal in fact) whose purpose is exactly that: keep a pin going on and off while the uP core goes on with other code. I don't think timer interrupts can be of any help here either, as the uP would be kept almost 100% busy into them anyway, but someone more experienced than me will probably tell you more about this.

I have took the advice for PaulS and removed all unnecessary global ints in my for loops. I have then added Serial.prints for additional debugging as suggested by wildbill. After running the sketch a few times with the same problem as mentioned before, I commented out lines from the loop.

It turns out that the parts using analogWrite are causing the issue. If those functions are commented out, I can run the sketch as long as I like. I would like to keep the functions but, I need a solution to do so. Any suggestions?

void RED_GREEN(){
  // Cycle color from red through to green
  // (In this loop we move from 100% red, 0% green to 0% red, 100% green)
  for (int g = 0; g <= 255; g += 5) {
    int r = 255-g;
    analogWrite(GREEN_LED_PIN, g);
    analogWrite(GREEN_LED_PIN2, g);
    analogWrite(RED_LED_PIN, r);
    analogWrite(RED_LED_PIN2, r);
    delay(DISPLAY_TIME);
  }

}

void GREEN_BLUE(){
  // Cycle color from green through to blue
  // (In this loop we move from 100% green, 0% blue to 0% green, 100% blue) 
  for (int b = 0; b <= 255; b += 5){
    int g = 255 - b;
    analogWrite(BLUE_LED_PIN, b);
    analogWrite(BLUE_LED_PIN2, b);
    analogWrite(GREEN_LED_PIN, g);
    analogWrite(GREEN_LED_PIN2, g);
    delay(DISPLAY_TIME);
  }

}

void BLUE_RED(){
  // Cycle cycle from blue through to red
  // (In this loop we move from 100% blue, 0% red to 0% blue, 100% red)   
  for (int r = 0; r <= 255; r += 5){
    int b = 255 - r;
    analogWrite(RED_LED_PIN, r);
    analogWrite(RED_LED_PIN2, r);
    analogWrite(BLUE_LED_PIN, b);
    analogWrite(BLUE_LED_PIN2, b);
    delay(DISPLAY_TIME);
  }

}

Here is the complete code at this point;

//const int ledpin1 = 3;//LED 1 RED
//const int ledpin2 = 5;//LED 1 GREEN
//const int ledpin3 = 6;//LED 1 BLUE

//const int ledpin4 = 9;//LED 2 RED
//const int ledpin5 = 10;//LED 2 GREEN
//const int ledpin6 = 11;//LED 2 BLUE

//const int ledpin7 = 12;//LED 3 RED
//const int ledpin8 = 13;//LED 3 GREEN
//const int ledpin9 = 7;//LED 3 BLUE

//const int ledpin10 = 14;//LED 4 RED
//const int ledpin11 = 15;//LED 4 GREEN
//const int ledpin12 = 16;//LED 4 BLUE

//const int ledpin13 = 17;// LED 5 RED
//const int ledpin14 = 18; // LED 5 GREEN
//const int ledpin15 = 19; // LED 5 BLUE

#include <SoftPWM.h>

const int ledPins[] = {
  3, 5, 6, 9, 10, 11, 12, 13, 7, 14, 15, 16, 17, 18, 19};       // an array of pin numbers to which LEDs are attached

const int pinCount = 15;           // the number of pins (i.e. the length of the array)


const int REDPins[] = {
  3, 9, 12, 14, 17};

const int GREENPins[] = {
  5, 10, 13, 15, 18};

const int BLUEPins[] = {
  6, 11, 7, 16, 19};

const int colorPins = 5;

// LED leads connected to PWM pins
const int RED_LED_PIN = 3;
const int GREEN_LED_PIN = 5;
const int BLUE_LED_PIN = 6;
const int RED_LED_PIN2 = 9;
const int GREEN_LED_PIN2 = 10;
const int BLUE_LED_PIN2 = 11;


// Length of time we spend showing each color
const int DISPLAY_TIME = 55; // In milliseconds
const int ON_TIME = 1000;//TIME ON FOR FLASHES
const int OFF_TIME = 10; // TIME ON FOR FLASHES In milliseconds
const int repeats = 8000;// how many times to reapeat color loops

void All(){
  for (int i = 0; i < repeats; i++){ 
    for (int i = 0 ; i < pinCount ; i++)  {
      digitalWrite(ledPins[i],HIGH);
      digitalWrite(ledPins[i],LOW);
    }
  }

}


void RED(){
  for (int i = 0; i <repeats; i++){ 
    for (int i = 0 ; i < colorPins ;i++)  {
      digitalWrite(REDPins[i],HIGH);
      digitalWrite(REDPins[i],LOW);
    }
  }


}

void GREEN(){
  for (int i = 0; i < repeats; i++){
    for (int i = 0 ; i < colorPins ; i++)  {
      digitalWrite(GREENPins[i],HIGH);
      digitalWrite(GREENPins[i],LOW);
    }
  }


}

void BLUE(){
  for (int i = 0; i < repeats; i++){
    for (int i = 0 ; i < colorPins ; i++)  {
      digitalWrite(BLUEPins[i],HIGH);
      digitalWrite(BLUEPins[i],LOW);
    }
  }


}

void AQUA(){
  for (int i = 0; i < repeats; i++){
    for (int i = 0 ; i < colorPins ; i++)  {
      digitalWrite(BLUEPins[i],HIGH);
      digitalWrite(GREENPins[i],HIGH);
      digitalWrite(BLUEPins[i],LOW);
      digitalWrite(GREENPins[i],LOW);
    }
  }


}

void PURPLE(){
  for (int i = 0; i < repeats; i++){
    for (int i = 0 ; i < colorPins ; i++)  {
      digitalWrite(BLUEPins[i],HIGH);
      digitalWrite(REDPins[i],HIGH);
      digitalWrite(BLUEPins[i],LOW);
      digitalWrite(REDPins[i],LOW);
    }
  }


}

void BROWN(){
  for (int i = 0; i < repeats; i++){ 
    for (int i = 0 ; i < colorPins ; i++)  {
      digitalWrite(GREENPins[i],HIGH);
      digitalWrite(REDPins[i],HIGH);
      digitalWrite(GREENPins[i],LOW);
      digitalWrite(REDPins[i],LOW);
    }
  }


}

void fadetry(){

  return;
}

void flashall(){
  for (int i = 0 ; i < pinCount ; i++)  {
    for (int i = 0; i < 2; i++){ 

      digitalWrite(ledPins[i], HIGH);
      delay(ON_TIME);
      digitalWrite(ledPins[i],LOW);
      delay(OFF_TIME);
    }
  }


}

void flash_RED(){
  for (int i = 0 ; i < colorPins; i++)  {
    for (int i = 0; i < 2; i++){     
      digitalWrite(REDPins[i], HIGH);
      delay(ON_TIME);
      digitalWrite(REDPins[i],LOW);
      delay(OFF_TIME);
    }
  }


}

void flash_GREEN(){
  for (int i = 0 ; i < colorPins; i++)  {
    for (int i = 0; i < 2; i++){     
      digitalWrite(GREENPins[i], HIGH);
      delay(ON_TIME);
      digitalWrite(GREENPins[i],LOW);
      delay(OFF_TIME);
    }
  }


}

void flash_PURPLE(){
  for (int i = 0 ; i < colorPins; i++)  {
    for (int i = 0; i < 2; i++){     
      digitalWrite(BLUEPins[i], HIGH);
      digitalWrite(REDPins[i], HIGH);
      delay(ON_TIME);
      digitalWrite(BLUEPins[i],LOW);
      digitalWrite(REDPins[i],LOW);
      delay(OFF_TIME);
    }
  }


}

void flash_AQUA(){
  for (int i = 0 ; i < colorPins; i++)  {
    for (int i = 0; i < 2; i++){     
      digitalWrite(BLUEPins[i], HIGH);
      digitalWrite(GREENPins[i], HIGH);
      delay(ON_TIME);
      digitalWrite(BLUEPins[i],LOW);
      digitalWrite(GREENPins[i],LOW);
      delay(OFF_TIME);
    }
  }


}

void flash_BLUE(){
  for (int i = 0 ; i < colorPins; i++)  {
    for (int i = 0; i < 2; i++){     
      digitalWrite(BLUEPins[i], HIGH);
      delay(ON_TIME);
      digitalWrite(BLUEPins[i],LOW);
      delay(OFF_TIME);
    }
  }


}

void RED_GREEN(){
  // Cycle color from red through to green
  // (In this loop we move from 100% red, 0% green to 0% red, 100% green)
  for (int g = 0; g <= 255; g += 5) {
    int r = 255-g;
    analogWrite(GREEN_LED_PIN, g);
    analogWrite(GREEN_LED_PIN2, g);
    analogWrite(RED_LED_PIN, r);
    analogWrite(RED_LED_PIN2, r);
    delay(DISPLAY_TIME);
  }

}

void GREEN_BLUE(){
  // Cycle color from green through to blue
  // (In this loop we move from 100% green, 0% blue to 0% green, 100% blue) 
  for (int b = 0; b <= 255; b += 5){
    int g = 255 - b;
    analogWrite(BLUE_LED_PIN, b);
    analogWrite(BLUE_LED_PIN2, b);
    analogWrite(GREEN_LED_PIN, g);
    analogWrite(GREEN_LED_PIN2, g);
    delay(DISPLAY_TIME);
  }

}

void BLUE_RED(){
  // Cycle cycle from blue through to red
  // (In this loop we move from 100% blue, 0% red to 0% blue, 100% red)   
  for (int r = 0; r <= 255; r += 5){
    int b = 255 - r;
    analogWrite(RED_LED_PIN, r);
    analogWrite(RED_LED_PIN2, r);
    analogWrite(BLUE_LED_PIN, b);
    analogWrite(BLUE_LED_PIN2, b);
    delay(DISPLAY_TIME);
  }

}

void FADE_IN_OUT(){
  for (int i = 0 ; i < pinCount ; i++)  {
    SoftPWMSet(ledPins[i],255);
    delay(170);
    SoftPWMSet(ledPins[i],0);
    delay(150);
  }

}

void setup()
{
  Serial.begin(9600);
  SoftPWMBegin() ;   
  // use a for loop to initialize each pin as an output:
  for (int i = 0 ; i < pinCount ; i++)  {
    SoftPWMSet(ledPins[i], 0);  
    SoftPWMSetFadeTime(ledPins[i], 1000, 1000);    
  }
}


void loop()
{
  Serial.println("red");
  RED();
  Serial.println("purple");
  PURPLE();
  Serial.println("blue");
  BLUE();
  Serial.println("all");
  All();
  Serial.println("aqua");
  AQUA();
  Serial.println("green");
  GREEN();
  Serial.println("brown");
  BROWN();
 // Serial.println("red/green");
 // RED_GREEN();
 // Serial.println("grn blue");
 // GREEN_BLUE();
 // Serial.println("blue/red");
 // BLUE_RED();
  Serial.println("flashall");
  flashall();
  Serial.println("flash red");
  flash_RED(); 
  Serial.println("flash purple");
  flash_PURPLE();
  Serial.println("flash aqua");
  flash_AQUA();
  Serial.println("flash blue");
  flash_BLUE();
  Serial.println("flash green");
  flash_GREEN();
  Serial.println("fade in out");
  FADE_IN_OUT();



}

Lots of things wrong.
First off this:-

for (int b = 0; b <= 255; b += 5){
    int g = 255 - b;

You are defining 256 values of g, each taking it’s own stack space you need to do :-

 int g;
for (int b = 0; b <= 255; b += 5){
    g = 255 - b;

For all the routines.

Then analogWrite(GREEN_LED_PIN2, g);
When you print out the value of GREEN_LED_PIN2 you get a value of 100.
I stopped looking after that.

void BLUE(){
  for (int i = 0; i < repeats; i++){
    for (int i = 0 ; i < colorPins ; i++)  {
      digitalWrite(BLUEPins[i],HIGH);
      digitalWrite(BLUEPins[i],LOW);
    }
  }
}

You can’t use the same name for both loop indexes.

If you change loop() to call JUST this function, exactly what happens?