July Wednesday 18

Bookmark and Share

Related Articles...

MILWAUKEE WI Arduino Meet Up Make Space


WANTED: Angle Investor Start-Up Funding

Large Industrial Zoned Arduino Make Space Acquired!

Email :

COASMailBox @ gmail.com

MILWAUKEE WI Raspberry Pi Meet Up Make Space


WANTED: Angle Investor Start-Up Funding

Large Industrial Zoned Raspberry Pi Make Space Acquired!

Email :

COASMailBox @ gmail.com

MILWAUKEE WI Internet of Things (IoT) Meet Up Make Space


WANTED: Angle Investor Start-Up Funding

Large Industrial Zoned Make Space Acquired!

Full Advanced Fabrication Facility, machine Shop, Welding, Electronics Lab Equipment Acquired!

Email :

COASMailBox @ gmail.com

MILWAUKEE WI Machine Repair, & Installation  - Tier 1 Business Support

Machine Technician Mechanic 20+ Years  Personal Experienced In Industrial Factory Machine Servicing, Rebuilding, Installation And Repair - Plus A 35+ Years Experienced Computer Engineer Service Technician Team Ready For Your Outsourced Market Advantage Needs!

Hartung Industrial - Member - CGI Science & Technology Group

Email :

COASMailBox @ gmail.com

2017 REVIEW | 'IoT & Embedded MAKER SPACE - MKE' Group


Arduino & Smart LED Strip

2017 OCTOBER | by Gene Casanova

Senior Systems Engineer

WS2812 LED Module

A 'WS2812 LED', is a smart integrated RGB Light Emitting Device; featuring an embedded integrated circuit (IC) for driving three embedded LED devices; one Red LED, one Green LED, And one Blue LED.

A 'WS2812 LED module, functions like a RGB (Red/Green/Blue) light emitting diode device.  The brightness of each color can be adjusted using pulse-width modulation (PWM) to one of 256 available levels.  This means there are 16,777,216 (2563) possible combinations of R-G-B colors.  produce any color from white to black (off state); salmon to sienna color.

WS2812 LED Module Pinouts

A WS2812 has 4 connections.

The INPUT Voltage.  This voltage is different for model version specifications:
WS2812 = Regulated power supply voltage between 5V and ~7V.  Less than 5V will reduce brightness, or will not power the device.  More than 7V will damage the device.
WS2812B = Regulated power supply voltage between 3.3V and ~5V.
The common, ground, 0V reference supply voltage.
Data is shifted out of this pin, to be connected to the input of another module (pixel) or left floating if it is the last link in a chain.

Match the input voltage with the logic level for the data lines (DI and DO).

Example: Power a WS2812B 5V and connect DI and DO with a logic level of 5V.

Communication Interface

The communication interface in a WS2812 module is an UART serial interface.  A logic 0 and a logic 1 require a square pulse of a specific length.

WS2812 Pulse Timing

The data is sent in a serial sequence, containing 24 bits; 8 bits for each color; followed by a low "reset" pulse of at least 50µs.


The larger a value of a bit, the brighter the emitted light energy

When every color is set to 0 (zero), the LED will be off.  When every color is set to 255 (maximum), the LED will be as bright and white as it can be.

A real-time processor is required to program a WS2812 module.

If one bit is less than a microsecond off, a color will be off.

WS2812 Addressable RGB LED STRIPS

Addressable RGB LED strips are available offering strips of WS2812 modules linked together.

CGI Computer Wares, offers high grade OEM WS2812 Addressable LED strips, in four versions.  1m or 5m lengths, with custom-cutable segmentation, and submersible waterproof sealed or bare.

The waterproofed models are rated IP65; dustproof and watertight.


Each end of the LED strip is terminated with a set of three colored wires; red, green, and a third color, can be yellow or other color.

The red (+) and green (-) leads, are the power input leads.  The third lead is the DATA line. The DATA line is paired with the common circuit ground.

RedVccWS2812 5~7 VDC3.3~5 VDC
Green DO/DI Serial DATA IN & DATA OUT.  Look for arrows and labels on strip.
White GNDGround; Common 0V (- VDC)

WS2812 Arduino Control


When powered with 5V, each LED draws about 50mA, at full brightness.   Every 30 LED modules may draw as much as 1.5 A.

When using an external power source, connect the power supply ground to the mirocontroller ground.  When using with an Arduino, connect the common ground of LED strips and the Arduino.

SW2812/WS2812B LED Strip Connector

Each LED strip comes with three attached leads at one end, with a three-pin JST SM connector. A mating connector is required to connect to a controlling device.

Arduino Control

A basic Arduino controller circuit, can power 14 WS2812B LED modules in a LED strip; using the 5V pin on an Arduino. Control many LED modules by using an external power supply as nessary.




Arduino Programing

An Arduino can control a WS2812B LED strip. Use the C "FastLED" library top speed program developement.

Click here to download the FastLED library.  Then load into the Arduino IDE application.

The following example, will drive a connected WS2812 as described above.

Upload the following code to an Arduino systemboard.

#include <FastLED.h>
#define LED_PIN     5
#define NUM_LEDS    14
#define BRIGHTNESS  64
#define LED_TYPE    WS2811


/* 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 animation, * 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;
TBlendType    currentBlending;
extern CRGBPalette16 myRedWhiteBluePalette;
extern const 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()
    static uint8_t startIndex = 0;
    startIndex = startIndex + 1; /* motion speed */
    FillLEDsFromPaletteColors( startIndex);
    FastLED.delay(1000 / UPDATES_PER_SECOND);

void FillLEDsFromPaletteColors( uint8_t colorIndex)
    uint8_t brightness = 255;
    for( int i = 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.

void ChangePalettePeriodically()
    uint8_t secondHand = (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.
void SetupTotallyRandomPalette()
    for( int i = 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.
void SetupBlackAndWhiteStripedPalette()
    // '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.
void SetupPurpleAndGreenPalette()
    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::Gray, // 'white' is too bright compared to red and blue

// Additionl 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.

Addressable RGB LED

The APA102 LED module adds more advanced intelligence to a RGB LED array module.  An APA102 LED module can be controlled through an integrated SPI interface.  The APA102 LED module features an high PWM frequency.  Use the C 'FastLED library' to develope source code faster for driving a SMART LED APA102.

Arduino Open Source Community member - Tier 1 Full Stack Developer

'IoT & Embedded MAKER SPACE - MKE'

CONACT to learn about a new group in METRO Area of WI & IL - Milwaukee, Racine, Kenosha, South Eastern WI And Northern IL, space and/or spaces - Forming Now!

We Have Industrial Zoned Making Space With Outfitted Machine Shop And Lab Space Available!  Multiple Dedicated Online Locations Available In Milwaukee 3rd Ward.

I am building a network of creative Makers/Doers!... Come Learn More, Join, Engage, Enjoy, Create A Solid Future Of Fun And Reward... Come Help..... Core Team Members Wanted, Or Simply be A Hangout Member Learning, Socializing/Networking... Start-Up Incubator Space, Students Tutoring Space, Retired... Hobbyists, Educators, Scientists, Researchers, Developers...

Mega Industrial Machines Building!!!!  AI Development.... Super Computing.... @ Tier 1 Level.  Locations looking to establish a network space, include Chicago IL, Melbourne Vic Australia.

WiFi Wisconsin - Great Lakes Open Source Internet Project

Join The Project.

Use The Technology Wisely & Keep It Simple

- Cheers!

Gene Casanova

Need More?   Need Help? ........Software, Network, System & Data Center Builder & Developer | Development Services Available - Freelance Small Jobs; To Outsourced Long Term Service Provider Contract Labor Available.

CGI Computer Wares | EST 1979

Send E-MailCONTACT: [click]@CGIComputerWares.com