0% found this document useful (0 votes)
2 views

pattern2

This document contains a code snippet for controlling a WS2812B LED strip using the FastLED library. It defines a setup for 100 LEDs with specific colors and brightness, and in the loop, it fills the strip with groups of colored LEDs while also creating a moving effect by turning off 5 LEDs at a time. The code includes a delay for speed control of the LED animations.

Uploaded by

Bharath Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

pattern2

This document contains a code snippet for controlling a WS2812B LED strip using the FastLED library. It defines a setup for 100 LEDs with specific colors and brightness, and in the loop, it fills the strip with groups of colored LEDs while also creating a moving effect by turning off 5 LEDs at a time. The code includes a delay for speed control of the LED animations.

Uploaded by

Bharath Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <FastLED.

h>

#define LED_PIN 6

#define NUM_LEDS 100

#define BRIGHTNESS 64

#define LED_TYPE WS2812B

#define COLOR_ORDER GRB

CRGB leds[NUM_LEDS];

void setup() {

FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds,


NUM_LEDS).setCorrection(TypicalLEDStrip);

FastLED.setBrightness(BRIGHTNESS);

void loop() {

// Array of colors for the LED groups

CRGB colors[] = {CRGB::Red, CRGB::Green, CRGB::Blue, CRGB::Yellow, CRGB::Cyan};

int numColors = sizeof(colors) / sizeof(colors[0]);

static int startPosition = 0;

// Fill the strip with groups of 20 LEDs of different colors

for (int i = 0; i < NUM_LEDS; i += 20) {

int colorIndex = (i / 20) % numColors;

for (int j = 0; j < 20 && (i + j) < NUM_LEDS; j++) {


leds[i + j] = colors[colorIndex];

// Set 5 LEDs to off state and move them

for (int j = 0; j < 5; j++) {

int ledPos = (startPosition + j) % NUM_LEDS;

leds[ledPos] = CRGB::Black;

FastLED.show();

delay(100); // Adjust delay for speed control

// Move the start position for the next frame

startPosition = (startPosition + 1) % NUM_LEDS;

You might also like