Go Down

Topic: Help with 3 color wave (Read 211 times) previous topic - next topic

Riker

Nov 11, 2017, 08:52 pm Last Edit: Nov 11, 2017, 11:12 pm by Riker
I found this code online that cycles through all colors in a wave pattern, however i would like to make it just cycle through red/purple/cyan/purple (repeat). I was able to come up with whats in the file 'RPCP.ino', but that just pushes the next color, instead of fading into the next. I would like for the wave to fit perfectly on what ever size LED strip I have (like in the simplehue file). I'm very new to the world of arduino, and have been at this for several hours. Any help would be greatly appreciated.


Simplehue:
Code: [Select]

#include "FastLED.h"
#define NUM_LEDS 15
#define DATA_PIN  5

CRGB leds[NUM_LEDS];
float ihue = 0;
float istep = 0.01;
int idelay = 0;

int numstops = round(255/NUM_LEDS);

void setup(){
  LEDS.setBrightness(50);
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
  memset(leds, 0,  NUM_LEDS * sizeof(struct CRGB));
}

void loop() {
    for(int i = 0; i < NUM_LEDS; i++) {
    leds[i] = CHSV(i*numstops+ihue, 255, 255);
    ihue += istep;
    if(ihue>= 255){
     ihue=0;
    }
  }
  delay(idelay);
  LEDS.show();
}




RPCP:

Code: [Select]
#include "FastLED.h"


#define NUM_LEDS 15


#define DATA_PIN 5
#define CLOCK_PIN 13


CRGB leds[NUM_LEDS];


void setup() {

    FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
     
}

void loop()
{

  for(int dot = 0; dot < NUM_LEDS; dot++)
 
  {
   
    leds[dot] = CRGB::Red;
    FastLED.show();
   
 
    leds[dot] = CRGB::Red;
   
    delay(100);
  }

    for(int dot = 0; dot < NUM_LEDS; dot++)
 
  {
   
    leds[dot] = CRGB::Red;
    FastLED.show();
   

    leds[dot] = CRGB::Purple;
   
    delay(100);
  }


for(int dot = 0; dot < NUM_LEDS; dot++)

  {
   
    leds[dot] = CRGB::Cyan;
    FastLED.show();
   
 
    leds[dot] = CRGB::Cyan;
   
    delay(100);
  }

  for(int dot = 0; dot < NUM_LEDS; dot++)
 
  {
   
    leds[dot] = CRGB::Cyan;
    FastLED.show();
   

    leds[dot] = CRGB::Purple;
   
    delay(100);
  }

 
}

PaulRB

#1
Nov 12, 2017, 10:58 am Last Edit: Nov 12, 2017, 10:58 am by PaulRB
So... At the first instant, the left most led will be red, the led 33% along the strip will be purple, the led at 66% will be cyan, and the right most led will be purple? The LEDs in between fade between those colours? Then when the animation begins, everything moves to the right and the colours that fall off the right end come back on at the left?

PS. Thanks for using code tags!

Go Up