How to turn "off" or black specific pixels on a LED string?

Hi super Arduino community!

I have 7 strings of 50 led pixels each one, in total 350 pixels.

I am coding them through arduino, all of them hooked to one PIN on the arduino.

And what I basically need is to "CANCEL" OR like "turn off" certain leds.

SO I need to add a line of code that will be somethig like

turn off pixel #4
turn off pixel #7
turn off pixel #10
or we could also "paint" them black ??

Someone has any idea on what line of code could work?
I am using the FastLED library =)

If you wanna see the codes you can check my GitHub page and if I'm not wrong there should be a way of finding a line of code that can work for all of the coding I have using FastLED library !

Codes

Thanks for your help!!

If you want help with your code then I strongly suggest that you post it here

The easier you make it to read and copy the code the more likely it is that you will get help

Please follow the advice given in the link below when posting code , use code tags and post the code here

1 Like

The LED colors are in an array usually called leds[]
To turn off the 4th LED you can write:
leds[3] = CRGB::Black; // leds numbered from 0
Similarly the 7th:
leds[6] = CRGB::Black;

1 Like

Thank you! I am new to the Arduino community and will read this guidelines for the next posts!

Until then my code is this

//***************************************************************

// Marc Miller, Jan. 2019
// Apr. 2019 - updated to use EVERY_N instead of delay()
// Apr. 2021 - cleaned up some duplicate code
//***************************************************************

#include "FastLED.h"
#define LED_TYPE WS2811
#define DATA_PIN 7
#define CLOCK_PIN 13
#define NUM_LEDS 349
#define COLOR_ORDER RGB
#define BRIGHTNESS 240
CRGB leds[NUM_LEDS];

// Set initial start position of each color
int16_t positionA = NUM_LEDS2/3;
int16_t positionB = NUM_LEDS/4;
int16_t positionC = 0;
int16_t positionD = NUM_LEDS
1/7;
int16_t positionE = NUM_LEDS/5;

const uint16_t holdTime = 120; // Adjusts speed of travel
int8_t delta = 1; // 1 or -1. Sets travel direction

//---------------------------------------------------------------
void setup() {
delay(1500); // Startup delay
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS)
.setCorrection(TypicalLEDStrip)
.setDither(BRIGHTNESS < 230);

// set master brightness control
FastLED.setBrightness(BRIGHTNESS);

}

//---------------------------------------------------------------
void loop() {

EVERY_N_MILLISECONDS(holdTime) {

// Fading tail effect.  Comment out for solid colors
fadeToBlackBy( leds, NUM_LEDS, 100);

// assign pixel colors

// leds[positionA] = CRGB::ForestGreen;
leds[positionA] = CRGB::MediumVioletRed;
leds[positionB] = CRGB::Indigo;
leds[positionC] = CRGB::DeepSkyBlue;
//leds[positionD] = CRGB::FairyLight;
//leds[positionD] = CRGB::Olive;
//leds[positionD] = CRGB::Chocolate;
leds[positionD] = CRGB::MediumSpringGreen;
leds[positionE] = CRGB::FireBrick;

FastLED.show();  // Show the pixels

// Advance position based on delta, and rollover if needed.
positionA = ((positionA + delta + NUM_LEDS) % NUM_LEDS);
positionB = ((positionB + delta + NUM_LEDS) % NUM_LEDS);
positionC = ((positionC + delta + NUM_LEDS) % NUM_LEDS);
positionD = ((positionD + delta + NUM_LEDS) % NUM_LEDS);
positionE = ((positionE + delta + NUM_LEDS) % NUM_LEDS);

}//end every_n

}

@izapaez
The easier you make it to read and copy the code the more likely it is that you will get help

Please follow the advice given in the link below when posting code , use code tags and post the code here

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.