Controlling WS2811 addressable LED's individually.

I am trying to figure out how to write the code to individually control up to 20 through-Hole 8mm RGB LED's with WS2811 driver.

The project I am doing is to make LED back lights for the dash of a truck, I want all the back lights to be one color, when you turn your lights in, but I also want certain lights, say the light that is in the water temp gauge, to turn to red if the water temp becomes to high, while all the others remain unchanged.

I have been able to do this, but I have to have each LED controlled from a separate output, and that causes to problems for me. 1) I don't have enough outputs to run 20 lights individually 2) it makes a lot of extra wiring in the dash i would rather not have.

So if I am understanding the idea of the addressable LED correct, I should be able to have one output, and run all the LED's in a series, and still be able to control each LED individually.

Thank you for the help.

WS2811 is just like WS2812, but with external LEDs. Check out the WS2812 libraries at adafruit.com for the neopixel.

Thanks for the reply, I haven't found any info in any forms, tutorial, or libraries yet, but I'm still looking. The biggest problem I am having, is that I can find all sorts of info to make the lights flash in a pattern, change all the colors of the rainbow, or even turn into a display, but whenever I look over the code for those type of projects, they don't have anything that shoes me how to call out 1 single LED to do something different then all the others. All I can seem to find is a predetermined sequence that runs through all the lights in a pattern. If i understood what I was looking at better, I might be able to figure out how they are doing it from the library file that is being used to bass it off of, but I am still new at this, and i doesn't make since to me yet.

Thanks again.

Start with making some of the sequences work, that will let you check out your wiring and make sure it is correct.

After that, you can store the data you want in an array, and send the data out to the displays when you decide it needs to be updated based on whatever your criteria is.

https://github.com/adafruit/Adafruit_NeoPixel

I can make the lights all work in a sequence, and i can control then the way I want using a different output for each LED, I just can't figure out how to combine the 2 ideas to work off 1 pin.

I don't understand what you mean by store the data in an array, but I am going to do some looking into that right now.

I would love to be able to find code that would show me how to be able to have LED1, LED2, and LED3 all controlled from Pin 13, with switch1, switch2, switch3, and switch4, all controlling 4 different inputs. So when you push switch1, LED1 turns red, and switch2 turns LED2 red, and when you push switch4, all 3 LED's turn blue, unless switch 1, 2, or 3 are pressed, then the switch that is pressed will keep that LED red. I hope that makes since. If I could figure out how to do that with just a few LED's I could expand it to do what I need.

void loop(){
if (digitalRead(switch1pin) == LOW){
// send out bytes 0-8 for color
}
if (digitalRead(switch2pin) == LOW){
// send out bytes 9-17 for color
}
if (digitalRead(switch3pin) == LOW){
// send out bytes 18-26 for color
}
if (digitalRead(switch4pin) == LOW){
// send out bytes 27-35 for color
}
}

Now borrow the library or code from adafruit to actually send the data out from:

byte colorArray[] = {
0x00, 0x01, 0x02, 0x03, 0x04,0x05,0x06,0x07,0x08, // data for switch 1 colors, 1 byte per color for each of 3 LEDs
0x00, 0x01, 0x02, 0x03, 0x04,0x05,0x06,0x07,0x08, // data for switch 2 colors
0x00, 0x01, 0x02, 0x03, 0x04,0x05,0x06,0x07,0x08, // data for switch 3 colors
0x00, 0x01, 0x02, 0x03, 0x04,0x05,0x06,0x07,0x08, // data for switch 4 colors
};

I feel like I am getting really close. I put this together the best I could, but i'm still not getting it to work, and i'm not sure where you would input the color. This is what I have so far.

Thanks again for all the help.

int ledPin = 12;
int switchPin1 = 2;        // light switch
int switchPin2 = 4;        // low air switch
int switchPin3 = 8;        // oil pressure switch
int switchPin4 = 9;        // coolant temp switch

void setup(){
  pinMode(ledPin, OUTPUT);
  pinMode(switchPin1, INPUT);
  pinMode(switchPin2, INPUT);
  pinMode(switchPin3, INPUT);
  pinMode(switchPin4, INPUT);
}

void loop(){ 
    byte colorArray[] = {
    0x00, 0x01, 0x02, 0x03, 0x04,0x05,0x06,0x07,0x08, // data for switch 1 colors, 1 byte per color for each of 3 LEDs
    0x00, 0x01, 0x02, 0x03, 0x04,0x05,0x06,0x07,0x08, // data for switch 2 colors
    0x00, 0x01, 0x02, 0x03, 0x04,0x05,0x06,0x07,0x08, // data for switch 3 colors
    0x00, 0x01, 0x02, 0x03, 0x04,0x05,0x06,0x07,0x08, // data for switch 4 colors
  };
  
  {
    colorArray[0-8] = 
  
  if (digitalRead(switchPin1) == LOW){
    digitalWrite(ledPin, colorArray[0-8]);
  }
  
  if (digitalRead(switchPin2) == LOW){
    digitalWrite(ledPin, byte(9-17));
  }
  
  if (digitalRead(switchPin3) == LOW)
  {
    digitalWrite(ledPin, byte(18-26));
  }
  
  if (digitalRead(switchPin4) == LOW){
    digitalWrite(ledPin, byte(27-35));
  }
}

I finally figured out how to get this to work. I found an example for a bulb test by FastLED. I have provided the code in case anyone else is looking for it. Now to do some more research on how to dim the LED’s.

Thank you for all of your help.

#include "FastLED.h"


////////////////////////////////////////////////////////////////////////////////////////////////////
//
// RGB Calibration code
//
// Use this sketch to determine what the RGB ordering for your chipset should be.  Steps for setting up to use:

// * Uncomment the line in setup that corresponds to the LED chipset that you are using.  (Note that they
//   all explicitly specify the RGB order as RGB)
// * Define DATA_PIN to the pin that data is connected to.
// * (Optional) if using software SPI for chipsets that are SPI based, define CLOCK_PIN to the clock pin
// * Compile/upload/run the sketch 

// You should see six leds on.  If the RGB ordering is correct, you should see 1 red led, 2 green 
// leds, and 3 blue leds.  If you see different colors, the count of each color tells you what the 
// position for that color in the rgb orering should be.  So, for example, if you see 1 Blue, and 2
// Red, and 3 Green leds then the rgb ordering should be BRG (Blue, Red, Green).  

// You can then test this ordering by setting the RGB ordering in the addLeds line below to the new ordering
// and it should come out correctly, 1 red, 2 green, and 3 blue.
//
//////////////////////////////////////////////////

#define NUM_LEDS 6

// Data pin that led data will be written out over
#define DATA_PIN 7
// Clock pin only needed for SPI based chipsets when not using hardware SPI
//#define CLOCK_PIN 8

CRGB leds[NUM_LEDS];

void setup() {
	// sanity check delay - allows reprogramming if accidently blowing power w/leds
   	delay(2000);

      // Uncomment one of the following lines for your leds arrangement.
      // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);

      // FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<LPD8806, RGB>(leds, NUM_LEDS);

      // FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
}

void loop() {
   leds[0] = CRGB::Red; 
   leds[1] = CRGB::Green;
   leds[2] = CRGB::Green;
   leds[3] = CRGB::Blue;
   leds[4] = CRGB::Blue;
   leds[5] = CRGB::Blue;
   FastLED.show();
   delay(1000);