Just in a couple of hours, thanks to your example, I have learned so much about controlling the Arduino and using the FastLED library. Thanks so much.
FWIW, this is my first piece of code that begins to give me what I want (You can see I’m a big fan of variables ):
And now I am able to create a display for any sized string with any sized fixed area. Now to get into the hard bits of code The ones where things have to move and be read and decisions made…
#include <FastLED.h>
#define DATA_PIN 6 // Arduino data pin > WS2812B
#define TYPE WS2812B // LED String type according to FastLED
#define ORDER GRB // Define colour display order - WS strings are GRB
#define NAV 5 //How many pixels for NAV area
#define Area_Size 20 //How many pixels per area total (including NAV)
#define NUM_LEDS Area_Size*4 // size of LED String
#define Area_NA 0 //Start of Nav Area A
#define Area_NB Area_Size*1 //Start of Nav Area B
#define Area_NC Area_Size*2 //Start of Nav Area C
#define Area_ND Area_Size*3 //Start of Nav Area D
#define Area_A Area_NA+NAV //Start of Area A
#define Area_B Area_NB+NAV //Start of Area B
#define Area_C Area_NC+NAV //Start of Area C
#define Area_D Area_ND+NAV //Start of Area D
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<TYPE, DATA_PIN, ORDER>(leds, NUM_LEDS); // initialise string
FastLED.showColor(CRGB::Black); // clear LEDs
FastLED.setBrightness(10);}
void setNavArea (int a, CRGB c) { // set up fixed NAV area
for (int n = a; n <= a+(NAV-1); n++) {
leds [n] = c;
}
}
// set up variable area
void setArea (int a, CRGB c) {
for (int n = a; n <= a+(Area_Size-NAV-1); n++) {
leds [n] = c;
}
}
void loop() {
{
// initialise NAV areas
setNavArea (Area_NA, CRGB::Red);
setNavArea (Area_ND, CRGB::Red);
setNavArea (Area_NB, CRGB::Blue);
setNavArea (Area_NC, CRGB::Blue);
// initialise variable areas
setArea (Area_A, CRGB::Orange);
setArea (Area_B, CRGB::White);
setArea (Area_C, CRGB::White);
setArea (Area_D, CRGB::Orange);
FastLED.show() ;} //display LEDs
}
When posting code on the forum you should use Code tags. You have been using Quote tags. Look at my list compared to yours to see the difference. Its the # button to the left of the quote button when composing a message. The Code tags preserve formatting so the code looks like it does in the Arduino IDE. Quote tags can make code difficult to read, especially with C/C++ where brackets and semicolons can get turned into smileys!