I created new code (removed what I found to be unnecessary).
I am hoping to understand what function(s) determine;
color, intensity, speed and LED positions and how to reverse the directions.
I would like to have the first 2 LEDs in the first column to illuminate with the others trailing behind at 50% brightness and staying when they are all filled.
Then to have a break that turns the LEDs black then to start another loop.
I would like to use CRGB color coding instead of the CVSR (it seems too complicated to come up with a color of choice).
There is some detail in the code of other flows that I am trying to create and hopefully by learning the items mentioned above I can come up with additional code.
//===================================================================================================================================================
// flow1 = (100% right to left 1st 2 LEDs then w/50% solid fill to follow and hold)
// flow2 = (100% left to right 1st 2 LEDs then w/50% solid fill to follow and hold)
// flow3 = (100% bottom row w/50% top row -->> 50% bottom row w/100% top row -->> 100% bottom row w/50% top row)
// flow4 = (start at bottom right to top left to look like a roman candle)
//==============
#include "FastLED.h" //Make sure to install the FastLED library into your Arduino IDE
//The total number of LEDs being used is 36
#define NUM_LEDS 18
// The data pin for the NeoPixel strip is connected to digital Pin 6 on the Arduino
#define TOP_ROW 6
#define BOTTOM_ROW 8
//Initialise the LED array, the LED Hue (ledh) array, and the LED Brightness (ledb) array.
CRGB leds[NUM_LEDS];
byte ledh[NUM_LEDS];
byte ledb[NUM_LEDS];
const int LEDSpeed = 10; //Speed of the LED animation effect. Make sure not to exceed the maxLEDSpeed value.
int maxLEDSpeed = 200; //Identifies the maximum speed of the LED animation sequence
int LEDposition = 0; //Identifies the LED position in the strip that the comet is currently at. The maximum position is NUM_LEDS-1 (eg. 143)
int oldPosition = 0; //Holds the previous position of the comet.
byte hue = 100; //Stores the Leading LED's hue value (colour)
byte sat = 25; //Stores the Leading LED's saturation value
byte tailHue = 0; //Stores the Comet tail hue value
byte hueRange = 0; //Colour variation of the tail (greater values have greater variation)
byte intensity = 150; //The default brightness of the leading LED
byte tailbrightness = intensity / 2; //Affects the brightness "/2 means 50%"
int animationDelay = 50; //The greater the animation delay, the slower the LED sequence. Calculated from LEDSpeed and MaxSpeed.
int flow = 1; //Used to choose which flow to show (***Don't change this variable***)
//===================================================================================================================================================
// setup() : Is used to initialise the LED strip
//===================================================================================================================================================
void setup() {
delay(1000); //Delay for two seconds to power the LEDS before starting the data signal on the Arduino
FastLED.addLeds<WS2812B, TOP_ROW, GRB>(leds, NUM_LEDS); //initialise the LED strip
FastLED.addLeds<WS2812B, BOTTOM_ROW, GRB>(leds, NUM_LEDS);
selectFlow(); //Select the next flow front
}
//===================================================================================================================================================
// loop() :
//===================================================================================================================================================
void loop() {
showLED(LEDposition, hue, sat, intensity);
//Adjust the hue of the tail so that it is a different colour from the leading LED. To reduce variation in tail colour, reduce the hueRange.
if (hue > (0 - hueRange)) {
tailHue = ((hue - hueRange), hue);
}
leds[LEDposition] = CHSV((tailHue), sat, tailbrightness); //Set the colour, saturation and brightness of the trailing LED
setDelay(LEDSpeed);
LEDposition++;
if (LEDposition > (NUM_LEDS )) {
for (int i = 0; i < 50; i++) {
showLED(LEDposition, hue, sat, intensity);
setDelay(LEDSpeed);
}
LEDposition = 0;
}
}
//===================================================================================================================================================
// showLED() : is used to illuminate the LEDs
//===================================================================================================================================================
void showLED(int pos, byte LEDhue, byte LEDsat, byte LEDbright) {
leds[pos] = CHSV(LEDhue, LEDsat, LEDbright);
FastLED.show();
}
//===================================================================================================================================================
// setDelay() : is where the speed of the LED animation sequence is controlled. The speed of the animation is controlled by the LEDSpeed variable.
// and cannot go faster than the maxLEDSpeed variable.
//===================================================================================================================================================
void setDelay(int LSpeed) {
animationDelay = maxLEDSpeed - abs(LSpeed);
delay(animationDelay);
}
//===================================================================================================================================================
// flow1 = (100% right to left 1st 2 LEDs then w/50% solid fill to follow and hold)
// flow2 = (100% left to right 1st 2 LEDs then w/50% solid fill to follow and hold)
// flow3 = (100% bottom row w/50% top row -->> 50% bottom row w/100% top row -->> 100% bottom row w/50% top row)
// flow4 = (start at bottom right to top left to look like a roman candle)
//====================================================================================
void selectFlow() {
flow++;
if (flow = 1) {
flow = 1;
}
switch (flow) {
case 1: { // white flow
hue = 100;
sat = 20;
hueRange = 0;
break;
}
}
}