Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

Controlling LED Strip (SK6812) with Arduino


#1

I have a setup which now seems to be working. I would like to turn on one light at a time, sequentially (with all other lights off). Does anyone have an existing script, or know how I can modify the one below to do this? Currently incrementally one additional light is turned on at a time (I only want one light on at a time.

#include <FastLED.h>

#define LED_PIN   8
#define NUM_LEDS  72

CRGB leds[NUM_LEDS];

void setup(){

  FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
  
}

void loop() {
  // put your main code here, to run repeatedly:

  for (int i = 0; i <= 72; i++) {
     leds[i] = CRGB (0,0,255);
     FastLED.show();
     delay(2000);
  }
}

#2

Hello.

You need to ensure all the LEDs are cleared by setting their RGB values to 0 before setting the color for the next LED. To do that, you could create a separate function setting the RGB values to 0 for each LED in your leds array. Alternatively, you could add led[i] = CRGB (0,0,0); after delay(2000); in your for loop to reset the previous LED color.

- Amanda