Skip to main content
added 1746 characters in body
Source Link
Oddacon
  • 185
  • 1
  • 1
  • 8

I added in a second loop that fades down redHere is the initial 0-255 rainbow. i I dunno if this is what you are trying to achieve but @bigjoshi took initiative from @bigjosh's answer. This just cycles thru each rgb from 0-255. @bigjosh does fade upstart red, but does not fade it down at 0-255 allowing for more for red colors. so here ya go:

    void loop(){ 

//start from red
  for( int colorStep=0; colorStep <= 255; colorStep++ ) {

  int r = 255;
  int g = 0;
  int b = colorStep; 

  // RednessNow startsloop atthough zeroeach of the LEDs and goesset upeach one to fullthe current color
  for(int x = 0; x < LED_COUNT; x++){
      leds[x] = CRGB(r,g,b);
  }

  // Display the colors we just set on the actual LEDs
      delay(10); 
      FastLED.show();
      }
    
    //into blue
      for( int colorStep=255; colorStep >= 0; colorStep-- ) {

      int r = colorStep;
      int g = 0;
      int b = 255;

      // BlueNow startsloop atthough fulleach of the LEDs and goesset downeach one to zerothe current color
      for(int gx = 0; x < LED_COUNT; x++){
          leds[x] = CRGB(r,g,b);
      }

      // NoDisplay greenthe neededcolors towe gojust set on the actual LEDs
  delay(10); 
  FastLED.show();
  }

//start from blue 
 to redfor( int colorStep=0; colorStep <= 255; colorStep++ ) {

      int r = 0;
      int g = colorStep;
      int b = 255; 

      // Now loop though each of the LEDs and set each one to the current color
      for(int x = 0; x < LED_COUNT; x++){
          leds[x] = CRGB(r,g,b);
      }

      // Display the colors we just set on the actual LEDs
  delay(10); 
  FastLED.show(); 
  } 

//into green
  for( int colorStep=255; colorStep >= 0; colorStep-- ) {

      int r = 0;
      int g = 255;
      int b = colorStep; 

      // RednessNow startsloop atthough zeroeach of the LEDs and goesset upeach one to fullthe current color
      for(int x = 0; x < LED_COUNT; x++){
          leds[x] = CRGB(r,g,b);
      }

      // Display the colors we just set on the actual LEDs
  delay(wait_time); 
  LEDS.show();
  }

//start from green
  for( int colorStep=0; colorStep <= 255; colorStep++ ) {

      int r = colorStep;
      int g = 255;
      int b = 0;

      // BlueNow startsloop atthough fulleach of the LEDs and goesset downeach one to zerothe current color
      for(int gx = 0; x < LED_COUNT; x++){
          leds[x] = CRGB(r,g,b);
      }

      // NoDisplay greenthe neededcolors towe gojust fromset blueon tothe redactual LEDs
  delay(wait_time); 
  LEDS.show();
  }

//into yellow
  for( int colorStep=255; colorStep >= 0; colorStep-- ) {

      int r = 255;
      int g = colorStep;
      int b = 0;

      // Now loop though each of the LEDs and set each one to the current color
      for(int x = 0; x < LED_COUNT; x++){
          leds[x] = CRGB(r,g,b);
      }

      // Display the colors we just set on the actual LEDs
  delay(10wait_time); 
  FastLEDLEDS.show();
  } 


} //end main loop

more documentation on the subject can be found: https://www.arduino.cc/en/tutorial/fading

I added in a second loop that fades down red. i dunno if this is what you are trying to achieve but @bigjosh answer does fade up red, but does not fade it down. so here ya go:

    void loop(){

  for( int colorStep=0; colorStep <= 255; colorStep++ ) {

  int r = colorStep;  // Redness starts at zero and goes up to full
  int b = colorStep;  // Blue starts at full and goes down to zero
  int g = 0;              // No green needed to go from blue to red

  // Now loop though each of the LEDs and set each one to the current color
  for(int x = 0; x < LED_COUNT; x++){
      leds[x] = CRGB(r,g,b);
  }

  // Display the colors we just set on the actual LEDs
  delay(10); 
  FastLED.show(); 
  }

  for( int colorStep=255; colorStep >= 0; colorStep-- ) {

  int r = colorStep;  // Redness starts at zero and goes up to full
  int b = colorStep;  // Blue starts at full and goes down to zero
  int g = 0;              // No green needed to go from blue to red

  // Now loop though each of the LEDs and set each one to the current color
  for(int x = 0; x < LED_COUNT; x++){
      leds[x] = CRGB(r,g,b);
  }

  // Display the colors we just set on the actual LEDs
  delay(10); 
  FastLED.show();
  }
}

more documentation on the subject can be found: https://www.arduino.cc/en/tutorial/fading

Here is the initial 0-255 rainbow. I dunno if this is what you are trying to achieve but i took initiative from @bigjosh's answer. This just cycles thru each rgb from 0-255. @bigjosh does start red at 0-255 allowing for more for red colors.

void loop(){ 

//start from red
  for( int colorStep=0; colorStep <= 255; colorStep++ ) {

  int r = 255;
  int g = 0;
  int b = colorStep; 

  // Now loop though each of the LEDs and set each one to the current color
  for(int x = 0; x < LED_COUNT; x++){
      leds[x] = CRGB(r,g,b);
  }

  // Display the colors we just set on the actual LEDs
      delay(10); 
      FastLED.show();
      }
    
    //into blue
      for( int colorStep=255; colorStep >= 0; colorStep-- ) {

      int r = colorStep;
      int g = 0;
      int b = 255;

      // Now loop though each of the LEDs and set each one to the current color
      for(int x = 0; x < LED_COUNT; x++){
          leds[x] = CRGB(r,g,b);
      }

      // Display the colors we just set on the actual LEDs
  delay(10); 
  FastLED.show();
  }

//start from blue 
  for( int colorStep=0; colorStep <= 255; colorStep++ ) {

      int r = 0;
      int g = colorStep;
      int b = 255; 

      // Now loop though each of the LEDs and set each one to the current color
      for(int x = 0; x < LED_COUNT; x++){
          leds[x] = CRGB(r,g,b);
      }

      // Display the colors we just set on the actual LEDs
  delay(10); 
  FastLED.show();
  } 

//into green
  for( int colorStep=255; colorStep >= 0; colorStep-- ) {

      int r = 0;
      int g = 255;
      int b = colorStep; 

      // Now loop though each of the LEDs and set each one to the current color
      for(int x = 0; x < LED_COUNT; x++){
          leds[x] = CRGB(r,g,b);
      }

      // Display the colors we just set on the actual LEDs
  delay(wait_time); 
  LEDS.show();
  }

//start from green
  for( int colorStep=0; colorStep <= 255; colorStep++ ) {

      int r = colorStep;
      int g = 255;
      int b = 0;

      // Now loop though each of the LEDs and set each one to the current color
      for(int x = 0; x < LED_COUNT; x++){
          leds[x] = CRGB(r,g,b);
      }

      // Display the colors we just set on the actual LEDs
  delay(wait_time); 
  LEDS.show();
  }

//into yellow
  for( int colorStep=255; colorStep >= 0; colorStep-- ) {

      int r = 255;
      int g = colorStep;
      int b = 0;

      // Now loop though each of the LEDs and set each one to the current color
      for(int x = 0; x < LED_COUNT; x++){
          leds[x] = CRGB(r,g,b);
      }

      // Display the colors we just set on the actual LEDs
  delay(wait_time); 
  LEDS.show();
  } 


} //end main loop
Source Link
Oddacon
  • 185
  • 1
  • 1
  • 8

I added in a second loop that fades down red. i dunno if this is what you are trying to achieve but @bigjosh answer does fade up red, but does not fade it down. so here ya go:

    void loop(){

  for( int colorStep=0; colorStep <= 255; colorStep++ ) {

  int r = colorStep;  // Redness starts at zero and goes up to full
  int b = colorStep;  // Blue starts at full and goes down to zero
  int g = 0;              // No green needed to go from blue to red

  // Now loop though each of the LEDs and set each one to the current color
  for(int x = 0; x < LED_COUNT; x++){
      leds[x] = CRGB(r,g,b);
  }

  // Display the colors we just set on the actual LEDs
  delay(10); 
  FastLED.show(); 
  }

  for( int colorStep=255; colorStep >= 0; colorStep-- ) {

  int r = colorStep;  // Redness starts at zero and goes up to full
  int b = colorStep;  // Blue starts at full and goes down to zero
  int g = 0;              // No green needed to go from blue to red

  // Now loop though each of the LEDs and set each one to the current color
  for(int x = 0; x < LED_COUNT; x++){
      leds[x] = CRGB(r,g,b);
  }

  // Display the colors we just set on the actual LEDs
  delay(10); 
  FastLED.show();
  }
}

more documentation on the subject can be found: https://www.arduino.cc/en/tutorial/fading