Programmable LEDs
LED strip
Dependencies
- Install the library FastLED: https://github.com/FastLED/FastLED
- Documentation: https://github.com/FastLED/FastLED/wiki/Overview
- Basic usage: https://github.com/FastLED/FastLED/wiki/Basic-usage
Examples online
- https://learn.adafruit.com/adafruit-neopixel-uberguide/the-magic-of-neopixels
- https://create.arduino.cc/projecthub/whimsy-makerspace/arduino-compatible-nano-neopixel-controller-6f0c4b
How to use

Install the FastLED library in the Arduino IDE.
How to connect the LED strip
Make sure the arrows are pointing to the right direction. The beginning of an arrow indicates the connection point to the Arduino board. The tip of the arrow show how the current flows in the strip.

Source code
// include library
#include<FastLED.h>
//define number of LED and pin
#define NUM_LEDS 4
#define DATA_PIN 3
// create the ld object array
CRGB leds[NUM_LEDS];
// define 3 byte for the random color
byte r, g, b;
float brightness;
void setup() {
Serial.begin(9600);
// init the LED object
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
// set random seed
randomSeed(analogRead(0));
}
void loop() {
// loop over the NUM_LEDS
for (int cur = 0; cur < NUM_LEDS; cur++) {
brightness = 50.0 / pow(2, cur);
FastLED.setBrightness(brightness); // range: 0-255
r = random(150, 200);
g = random(100, 150);
b = random(0, 50);
//set the value to the led AND turn on
leds[cur] = CRGB(r, g, b); FastLED.show();
FastLED.delay(200);
// turn off previous
leds[cur] = CRGB::Black; FastLED.show();
Serial.println(cur, DEC);
}
}