1

I wish to blink only one led (number two in the strip) bit it does not do so, any idea why and how can I do it?

Code:

#include "FastLED.h"

//Number of LEDs #define NUM_LEDS 9

//Define our clock and data lines #define DATA_PIN 11 #define CLOCK_PIN 13

//Create the LED array CRGB leds[NUM_LEDS];

void setup() { FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, BGR>(leds, NUM_LEDS); FastLED.setBrightness(5); }

void loop() { leds[0] = CRGB::Blue; leds[1] = CRGB::Green;

//Blink this one only leds[2] = CRGB::Red; leds[2] = CRGB::Black; delay(500); leds[2] = CRGB::Red;

leds[3] = CRGB::White; leds[4] = CRGB::Purple; leds[5] = CRGB::Green; leds[6] = CRGB::Blue; leds[7] = CRGB::Yellow; leds[8] = CRGB::Red; FastLED.show(); }

AsiJapan
  • 113
  • 4
  • 2
    does not do so does not describe what it does ... please describe what you expect to happen, and what you observe happening – jsotola Feb 06 '21 at 03:11
  • Let me translate that for you. The OP want the 2nd LED blink while other LEDs stay the same, but the code he wrote didn't do that. He didn't know how to code and wanted to learn from some experience guy how to do that. Is that clear enough? – SimonVu14 Feb 06 '21 at 13:15

1 Answers1

2

Everytime, that you want the LEDs to change, you need to call the FastLED.show() function. You are doing that only once after you set the values multiple times. Also you need 2 delays in total (1 for the LED being on, 1 for it being off).

The workflow for blinking an LED would be:

Set LED to on
Call show function
Delay
Set LED to off
Call show function
Delay

You need to translate that to code.

chrisl
  • 16,257
  • 2
  • 17
  • 27