// https://wokwi.com/projects/377183196488010753

#include <FastLED.h> // https://github.com/FastLED/FastLED

#define PIN 0   // ATtiny85 Neopixel pin
#define led 1   // Number of Neopixels
#define MAX 255 // Maximum brightness
#define MIN 0   // Minimum brightness

CRGB leds[led];

void setup() {
  FastLED.addLeds<WS2812, PIN, GRB>(leds, led);
  FastLED.clear();
  FastLED.setBrightness(MAX);
  FastLED.show();
}

void loop() {
  // zero(); // startup, pixel 0 random max R, G, B
  // blink(); // Helo, Blink!
  // candle(); // candle flicker with orange color values
  // diffused(); // white pixel for diffusion media (paper, plastic, et c.)
  fadeHSV(); // Hue, Saturation, Value transitions
  // rgbycm(); // six basic colors cycling
  // rnd(); // any of (256 * 256 * 256) = 16,777,216 colors
}

//**************************************************
// patterns
//**************************************************

void blink() { // Hello, Blink!
  leds[0] = CRGB::White; FastLED.show(); delay(500);
  leds[0] = CRGB::Black; FastLED.show(); delay(500);
}

void zero() { // at startup, pixel 0 random max R, G, B
  leds[0] =  CRGB(random(2) * random(MAX), // 0 or 1 removes or includes the color
                  random(2) * random(MAX),
                  random(2) * random(MAX));
  FastLED.show();
  delay(100);
}

void candle() { // candle flicker with orange color values without diffuser
  int r = random (127, 255);
  int g = random (50, 127);
  int b = random (0, 15);
  leds[0] = CRGB(r, g, b);
  FastLED.show();
  delay(random(63, 255));
}

void diffused() { // white pixel flicker for beneath diffusion media (paper, plastic, et c.)
  int i = random (63, 255);
  leds[0] = CRGB(i, i, i);
  FastLED.show();
  delay(random(63, 255));
}

void rgbycm() { // basic seven colors cycling
  int pause = 500;
  leds[0] = CRGB(MAX, 000, 000); FastLED.show(); delay(pause); // red
  leds[0] = CRGB(000, MAX, 000); FastLED.show(); delay(pause); // grn
  leds[0] = CRGB(000, 000, MAX); FastLED.show(); delay(pause); // blu
  leds[0] = CRGB(MAX, MAX, 000); FastLED.show(); delay(pause); // yel
  leds[0] = CRGB(000, MAX, MAX); FastLED.show(); delay(pause); // cyn
  leds[0] = CRGB(MAX, 000, MAX); FastLED.show(); delay(pause); // mag
  leds[0] = CRGB(MAX, MAX, MAX); FastLED.show(); delay(pause); // wht
}

void fadeHSV() { // Hue, Saturation, Value transitions
  uint8_t speed = 1; uint8_t change = 10; uint8_t hue = beat8(speed, 255);
  fill_rainbow(leds, led, hue, change);
  FastLED.show();
}

void rnd() { // random r, random g, random b
  leds[0] = CRGB(random(255), random(255), random(255));
  FastLED.show();
  delay(500);
}


/************************************************************************************************
  ATTINY85 information
*************************************************************************************************
                                       +-----+
             PCINT5/-RESET/ADC0/dW/PB5 |1 * 8| VCC
      PCINT3/XTAL1/CLKI/-OC1B/ADC3/PB3 |2   7| PB2/SCK/USCK/SCL/ADC1/T0/INT0/PCINT2
  PWM4/PCINT4/XTAL2/CLKO/OC1B/ADC2/PB4 |3   6| PB1/MISO/DO/AIN1/OC0B/OC1A/PCINT1/PWM1
                                   GND |4   5| PB0/MOSI/DI/SDA/AIN0/OC0A/-OC1A/AREF/PCINT0/PWM0
                                       +-----+
*************************************************************************************************

  // BlinkM
  // https://thingm.com/products/blinkm

  // BlinkM-MinM
  // https://thingm.com/products/blinkm-minm/

  // sequencer
  // https://thingm.com/products/blinkm/
  // https://github.com/todbot/LinkM/releases/download/v20150915/BlinkMSequencer2-win.zip

  // https://thingm.com/products
  // https://raw.githubusercontent.com/todbot/LinkM/master/docs/LinkM_datasheet.pdf

  // https://www.instructables.com/Ghetto-Pixels-Building-an-open-source-BlinkM/
  // https://forum.arduino.cc/t/desperately-seeking-minm-leds-from-thingm/1173261

************************************************************************************************/
ATTINY8520PU