Altium
Arduino Projects

WS2811 RGB Led Strip with Arduino,FastledWS2811 12V

Arduino fastled Color Palette Tutorial using WS2811 RGB Led Strip

WS2811 RGB Led Strip:

WS2811 RGB Led Strip

WS2811 RGB Led Strip with Arduino, Fastled WS2811 12V– Recently, I got a 5 meters long, Programmable and Addressable, IP67 Tube Waterproof, 12V WS2811 RGB Led Strip from SunFounder for only 23.99 dollars with free shipping. This RGB Led strip has a total of 150 Addressable LEDs; 30 LEDs/meter. Each and every Led in this strip can be individually programmed using a microcontroller board like Arduino, ESP8266, ESP32 WiFi + Bluetooth Module, STM32, etc, using only one pin on your controller board.

Since this is my first time using the WS2811 Led strip, so first I am going to start with the Arduino and then later I will use this LED strip with other controller boards as well. I will make a complete series covering, how to control the WS2811 Led strip using Android Bluetooth Application, IR Remote controller, WiFi, Long Range Radio transceiver modules like Lora, and NRF24L01, etc. So, consider subscribing if you don’t want to miss any of my upcoming projects.

Anyway, as usual, before I am going to share with you its technical specifications, It’s interfacing with Arduino, Library installation, and different programs. First, I am going to share with you the final test results and afterward, I will explain everything else.




Altium Designer + Altium 365 + Octopart:

Arduino LoRa Free SMS

Altium 365 lets you hold the fastest design reviews ever. Share your designs from anywhere and with anyone with a single click. it’s easy, leave a comment tagging your teammate and they’ll instantly receive an email with a link to the design. Anyone you invite can open the design using a web browser. Using the browser interface, you’re able to comment, markup, cross probe, inspect, and more. Comments are attached directly to the project, making them viewable within Altium designer as well as through the browser interface. Design, share, and manufacture, all in the same space with nothing extra to install or configure. Connect to the platform directly from Altium Designer without changing how you already design electronics. Altium 365 requires no additional licenses and comes included with your subscription plan.

Get real-time component insights as you design with Octopart built into Altium 365. Octopart is the fastest search engine for electronic parts and gives you the most up-to-date part data like specs, datasheets, cad models, and how much the part costs at different amounts etc. Right in the design environment so you can focus on your designs. Start with Altium Designer and Activate Altium 365. Search for electronic parts on Octopart.

I am using my 4S lithium Ion Battery pack to power up the Entire Led strip and the Arduino board. You can read my previous article if you want to make the same Lithium Ion Battery pack or you can use a 12V adaptor.

I have already uploaded the Example number 1 code. So, let’s go ahead and power up the Led Strip and Arduino Board.

WS2811 RGB Led Strip

I successfully tested more than 10 different projects. I didn’t had to write even a single line of code except changing the number of the LEDs in the strip. The Library itself consists of so many example codes which can also be modified.

If you don’t like any of those readymade LEDs effects, you can also try the Adafruit library or the pixels library or you can write your own unique code and make some cool animations. Anyway, now I am going to explain all the other important things, so, without any further delay, let’s get started!!!



Amazon Links:

WS2811 LED Strip

Arduino Nano

WS2811 LED Strip SunFounder

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

WS2811 Led Strip:

WS2811 RGB Led Strip

This is a 5 meters long, Programmable and Addressable, IP67 Tube Waterproof, 12V WS2811 RGB Led Strip. This RGB Led strip has a total of 150 Addressable LEDs; 30 LEDs/meter.  Each and every Led in this strip can be individually animated using a controller board like Arduino, ESP8266, ESP32 WiFi + Bluetooth Module, STM32, etc, using only pin on your controller board.

Every 3 LEDs can be cut without damaging the rest of the strip to help you meet different size needs.

The Operating voltage is 12V and its 7.2Watts/meter and the chip model is WS2811. There are 10 WS2811 ICs per meter. The Entire Led strip is covered with a Silicone tube which makes it IP67 Waterproof.

WS2811 RGB Led Strip

This LED strip has got connectors on both the ends, this way multiple LED strips can be connected without any issues.The RED wires are 12v wires, the green wire is the Din wire, and the White wires are the ground wires.



Parameters:

Product Model: BTF-5050RGB3T-2811-12V
Color: full color
Working voltage: DC12V
Power: 7.2W/M
LED number/m: 30 LEDs/M
IC model: WS2811
Number of IC per meter: 10pcs
Waterproof level:IP67(casing waterproof)
Luminous angle: 120°
Wavelength: R: 620-630λ; G: 520-525λ; B: 465-470λ.
Light intensity: R: 500-600mcd; G: 900-1200mcd; B: 250-310mcd.
Luminous flux: R: 1.68lm; G: 3.2lm; 0.84lm.
Size specification: 5000x10mm
Weight/roll: 320g

Wide Application

It can be used to make led screen, led wall, advertising boards and widely applied to hotel, KTV, bars, Outdoor advertising signs, wedding party lighting, home and car decoration, city skyline, building outline and so on.

WS2811 LED Strip with Arduino:

WS2811 RGB Led Strip

The data in or DIN pin on the WS2811 LED strip is connected with the D5 pin on the Arduino. And the +12V and GND pins are connected with the 12V external power supply. In my case I am using a 4S lithium Ion Battery pack. And I am using a 5V regulated power supply to power up the Arduino board. As you can see the Output and ground legs of the 7805 voltage regulator are connected with the VIN and GND pins of the Arduino.

For the easy interfacing, I also soldered this DC Female power jack with the Red and White wires and now I can easily connect a power supply.

You can download the Gerber files of the Arduino Nano Development board from PCBWay.

WS2811 RGB Led Strip

Finally, I connected everything as per the circuit diagram.

WS2811 RGB Led Strip

And now let’s take a look at the programming.



Required Library:

As usual, before you start the programming, first of all, make sure you install the FastLED library. To install this library simply go to the Sketch Menu, then to Include Library, and click on the Manage Libraries, and Search for the fastled.

WS2811 RGB Led Strip

As you can see I have already installed this library.

WS2811 LED Strip Arduino Code:

After installing the library, you can start with the readymade example codes.

WS2811 RGB Led Strip

As you can see there are more than 20 example codes. You can check these one by one and you will get the idea how the code works. Let’s go ahead and open one example code.




ColorPalette Example Code:

#include <FastLED.h>

#define LED_PIN     5

#define NUM_LEDS    150

#define BRIGHTNESS  250

#define LED_TYPE    WS2811

#define COLOR_ORDER GRB

CRGB leds[NUM_LEDS];

#define UPDATES_PER_SECOND 100

// This example shows several ways to set up and use ‘palettes’ of colors

// with FastLED.

//

// These compact palettes provide an easy way to re-colorize your

// animation on the fly, quickly, easily, and with low overhead.

//

// USING palettes is MUCH simpler in practice than in theory, so first just

// run this sketch, and watch the pretty lights as you then read through

// the code.  Although this sketch has eight (or more) different color schemes,

// the entire sketch compiles down to about 6.5K on AVR.

//

// FastLED provides a few pre-configured color palettes, and makes it

// extremely easy to make up your own color schemes with palettes.

//

// Some notes on the more abstract ‘theory and practice’ of

// FastLED compact palettes are at the bottom of this file.

CRGBPalette16 currentPalette;

TBlendTypecurrentBlending;

extern CRGBPalette16 myRedWhiteBluePalette;

externconst TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;

void setup() {

delay( 3000 ); // power-up safety delay

FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );

FastLED.setBrightness(  BRIGHTNESS );

currentPalette = RainbowColors_p;

currentBlending = LINEARBLEND;

}

void loop()

{

ChangePalettePeriodically();

static uint8_t startIndex = 0;

startIndex = startIndex + 1; /* motion speed */

FillLEDsFromPaletteColors(startIndex);

FastLED.show();

FastLED.delay(1000 / UPDATES_PER_SECOND);

}

voidFillLEDsFromPaletteColors( uint8_t colorIndex)

{

uint8_t brightness = 255;

for(inti = 0; i< NUM_LEDS; ++i) {

leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);

colorIndex += 3;

    }

}

// There are several different palettes of colors demonstrated here.

//

// FastLED provides several ‘preset’ palettes: RainbowColors_p, RainbowStripeColors_p,

// OceanColors_p, CloudColors_p, LavaColors_p, ForestColors_p, and PartyColors_p.

//

// Additionally, you can manually define your own color palettes, or you can write

// code that creates color palettes on the fly.  All are shown here.

voidChangePalettePeriodically()

{

uint8_tsecondHand = (millis() / 1000) % 60;

static uint8_t lastSecond = 99;

if(lastSecond != secondHand) {

lastSecond = secondHand;

if(secondHand ==  0)  { currentPalette = RainbowColors_p;         currentBlending = LINEARBLEND; }

if(secondHand == 10)  { currentPalette = RainbowStripeColors_p;   currentBlending = NOBLEND;  }

if(secondHand == 15)  { currentPalette = RainbowStripeColors_p;   currentBlending = LINEARBLEND; }

if(secondHand == 20)  { SetupPurpleAndGreenPalette();             currentBlending = LINEARBLEND; }

if(secondHand == 25)  { SetupTotallyRandomPalette();              currentBlending = LINEARBLEND; }

if(secondHand == 30)  { SetupBlackAndWhiteStripedPalette();       currentBlending = NOBLEND; }

if(secondHand == 35)  { SetupBlackAndWhiteStripedPalette();       currentBlending = LINEARBLEND; }

if(secondHand == 40)  { currentPalette = CloudColors_p;           currentBlending = LINEARBLEND; }

if(secondHand == 45)  { currentPalette = PartyColors_p;           currentBlending = LINEARBLEND; }

if(secondHand == 50)  { currentPalette = myRedWhiteBluePalette_p; currentBlending = NOBLEND;  }

if(secondHand == 55)  { currentPalette = myRedWhiteBluePalette_p; currentBlending = LINEARBLEND; }

    }

}

// This function fills the palette with totally random colors.

voidSetupTotallyRandomPalette()

{

for(inti = 0; i< 16; ++i) {

currentPalette[i] = CHSV( random8(), 255, random8());

    }

}

// This function sets up a palette of black and white stripes,

// using code.  Since the palette is effectively an array of

// sixteen CRGB colors, the various fill_* functions can be used

// to set them up.

voidSetupBlackAndWhiteStripedPalette()

{

    // ‘black out’ all 16 palette entries…

fill_solid(currentPalette, 16, CRGB::Black);

    // and set every fourth one to white.

currentPalette[0] = CRGB::White;

currentPalette[4] = CRGB::White;

currentPalette[8] = CRGB::White;

currentPalette[12] = CRGB::White;

}

// This function sets up a palette of purple and green stripes.

voidSetupPurpleAndGreenPalette()

{

    CRGB purple = CHSV( HUE_PURPLE, 255, 255);

    CRGB green  = CHSV( HUE_GREEN, 255, 255);

    CRGB black  = CRGB::Black;

currentPalette = CRGBPalette16(

green,  green,  black,  black,

purple, purple, black,  black,

green,  green,  black,  black,

purple, purple, black,  black );

}

// This example shows how to set up a static color palette

// which is stored in PROGMEM (flash), which is almost always more

// plentiful than RAM.  A static PROGMEM palette like this

// takes up 64 bytes of flash.

const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM =

{

    CRGB::Red,

    CRGB::Gray, // ‘white’ is too bright compared to red and blue

    CRGB::Blue,

    CRGB::Black,

    CRGB::Red,

    CRGB::Gray,

    CRGB::Blue,

    CRGB::Black,

    CRGB::Red,

    CRGB::Red,

    CRGB::Gray,

    CRGB::Gray,

    CRGB::Blue,

    CRGB::Blue,

    CRGB::Black,

    CRGB::Black

};

// Additional notes on FastLED compact palettes:

//

// Normally, in computer graphics, the palette (or “color lookup table”)

// has 256 entries, each containing a specific 24-bit RGB color.  You can then

// index into the color palette using a simple 8-bit (one byte) value.

// A 256-entry color palette takes up 768 bytes of RAM, which on Arduino

// is quite possibly “too many” bytes.

//

// FastLED does offer traditional 256-element palettes, for setups that

// can afford the 768-byte cost in RAM.

//

// However, FastLED also offers a compact alternative.  FastLED offers

// palettes that store 16 distinct entries, but can be accessed AS IF

// they actually have 256 entries; this is accomplished by interpolating

// between the 16 explicit entries to create fifteen intermediate palette

// entries between each pair.

//

// So for example, if you set the first two explicit entries of a compact

// palette to Green (0,255,0) and Blue (0,0,255), and then retrieved

// the first sixteen entries from the virtual palette (of 256), you’d get

// Green, followed by a smooth gradient from green-to-blue, and then Blue.



About the code:

Once you open the program. Enter the pin number which is connected with the Data in pin on the LED strip, Next, enter the number of LEDs you want to control. Specify the brightness and update the chip type if incase your LED strip has a different chip. Make same changes in all the other example codes. If you want to see different example codes in action then you should watch my video.

Watch Video Tutorial

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button