#include <FastLED.h>
#define NUM_LEDS 6
#define DATA_PIN PB3
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
randomSeed(analogRead(0) + analogRead(1) + analogRead(2) + analogRead(3) + analogRead(4) + analogRead(5));
}
void random_pixel_color(int ledID) {
for (byte colorID = 0; colorID < 3; colorID++) {
leds[ledID][colorID] = random(0, 255);
}
FastLED.show();
}
void turn_pixel_off(int ledID) {
leds[ledID] = CRGB::Black;
FastLED.show();
}
void loop() {
int randomLedID = random(0,NUM_LEDS);
byte on_or_off = random(0,10);
if (on_or_off != 0) {
random_pixel_color(randomLedID);
} else {
turn_pixel_off(randomLedID);
}
delay(random(150,350));
}
Comments