Home
About
Blog
Media Gallery

Adressable RGB


I used one of these with a Digispark board:
https://www.akasa.com.tw/search.php?seed=AK-LD07-60RB

To pulsate with pink color in a loop for Kristine's PC:
See Media Gallery for a demo video.

Arduino IDE
(4 different colors picked at random as example)
// include library
#include<FastLED.h>

//define number of LED and pin
#define NUM_LEDS 15
#define DATA_PIN 1
#define BRIGHTNESS 0
#define MAX_BRIGHTNESS 200

CRGB leds[NUM_LEDS];
byte  r, g, b;
int FargeValg = 0;
byte Farger[4][3] = {
  {0, 0, 225},      // blue
  {30, 144, 255},   // dodgerblue
  {50, 205, 50},    // limegreen
  {0, 255, 0}       // lime
};
int DimVal = 0;
bool TurnLightOn = true;

void setup() {
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
  //FastLED.setBrightness(BRIGHTNESS);
  randomSeed(analogRead(0));
}


void loop() {
  // Sett lysstyrke.
  if (TurnLightOn) {
    ++DimVal;
    if (DimVal == MAX_BRIGHTNESS)
      TurnLightOn = false;
  
  } else {
    --DimVal;
    if (DimVal == 0) {
      TurnLightOn = true;
      FargeValg = random(0,4);
    }
  }
  
  for (int n = 0; n < NUM_LEDS; n++) {
    // Sett fargevalg.
    leds[n] = CRGB (Farger[FargeValg][0], Farger[FargeValg][1], Farger[FargeValg][2]);
    leds[n].maximizeBrightness(DimVal);
  }

  FastLED.show();
  FastLED.delay(10);
}


Original Post: Feb 2nd, '22 19:05 CET.
Updated: Feb 2nd, '22 19:13 CET.

Tags: Arduino