// Randomly assigns colors to blocks of pixels.
//
// Marc Miller, Feb 2021
//---------------------------------------------------------------
#include <FastLED.h>
#define NUM_BLOCKS 6 // number of blocks
#define PPB 5 // pixels per block
#define NUM_LEDS NUM_BLOCKS * PPB // 30
CRGB leds[NUM_LEDS];
uint8_t hue, sat;
void setup() {
FastLED.addLeds<NEOPIXEL, 13>(leds, NUM_LEDS);
// Initailly give all blocks a color
for(int x = 0; x < NUM_BLOCKS; x++) {
hue = random8();
sat = random8(150,255);
for(int i = 0; i < PPB; i++) {
leds[(x * PPB) + i] = CHSV(hue, sat, 255);
}
}
}
void loop() {
EVERY_N_MILLISECONDS(500) {
uint8_t r = random8(3); // how many blocks to update at the same time
for(uint8_t x = 0; x < r; x++){
uint8_t block = random8(NUM_BLOCKS); // pick which block to update
hue = random8();
sat = random8(150,255);
for(int i = 0; i < PPB; i++) {
leds[(block * PPB) + i] = CHSV(hue, sat, 255);
}
}
}
FastLED.show();
}