// https://wokwi.com/projects/408578815245853697
// for https://forum.arduino.cc/t/create-code-for-a-semi-random-fastled-pattern/1299988

// Modified from https://wokwi.com/projects/374907938100932609

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>  // Required for 16 MHz Adafruit Trinket
#endif

#define PIN_NEO_PIXEL 4  // Arduino pin that connects to NeoPixel
#define NUM_PIXELS 100    // The number of LEDs (pixels) on NeoPixel

#define DELAY_INTERVAL 250  // 250ms pause between each pixel

Adafruit_NeoPixel NeoPixel(NUM_PIXELS, PIN_NEO_PIXEL, NEO_GRB + NEO_KHZ800);

byte pixDeck[NUM_PIXELS]; // 255 max

void setup() {
  NeoPixel.begin();  // INITIALIZE NeoPixel strip object (REQUIRED)
  for (int ii = 0; ii < NUM_PIXELS; ++ii){
    pixDeck[ii] = ii;
  }
}

void randomizePixDeck(int nn) {
  for (int ii = 0; ii < nn; ++ii) {
    int jj = random(ii, NUM_PIXELS );
    int save = pixDeck[ii];
    pixDeck[ii] = pixDeck[jj];
    pixDeck[jj] = save;
  }
}

void loop() {
  randomPixes(7);
}

void randomPixes(int num){
  const uint32_t interval = 2000;
  static uint32_t last = -interval;
  uint32_t now = millis();
  if (now - last >= interval) {
    last = now;
    NeoPixel.clear();
    randomizePixDeck(num);
    for (int jj = 0; jj < num; ++jj) {
      NeoPixel.setPixelColor(pixDeck[jj], NeoPixel.Color(255, 0xbf, 0));
    }
    NeoPixel.show();
  }
}