WS2812B - Basics

Materials

  • AmebaD [ AMB21 / AMB22 / AMB23 / BW16 ] x1

  • WS2812B LED Strip / Ring / Stick / Board x1

Example

Introduction

In this example, we will be using the AmebaD board to control the WS2812B RGB LED, using the SPI peripheral to create the waveform necessary for the LEDs.

WS2812B basics allows you to control a single LED with a color or fill all the LED with the same color.

Procedure

Firstly, connect the WS2812B to the Ameba board as shown in the following diagrams.

AMB21/AMB22 Wiring Diagram:

../../../../_images/image185.png

AMB23 Wiring Diagram:

../../../../_images/image276.png

BW16 Wiring Diagram:

../../../../_images/image351.png

BW16-TypeC Wiring Diagram:

../../../../_images/image439.png

To light up one individual LED or multiple LEDs with the same color, use WS2812B_Basics.

Open the example in “File” “Example” “AmebaWS2812B” “WS2812B_Basics”

../../../../_images/image528.png

In the sample code, modify NUM_OF_LEDS to be the number of LEDs that you have connected.

../../../../_images/image616.png

Next, compile and upload to Ameba, then press the reset button. You will see the first 3 LED light up with red, green, and blue light color individually and after a while all the LED will be filled with a color.

../../../../_images/image713.png ../../../../_images/image89.png

Code Reference

[1] WS2812B Datasheet:

https://cdn-shop.adafruit.com/datasheets/WS2812B.pdf