Ameba Arduino: [RTL8195AM] [RTL8710AF] Use WS2812B 4x4 RGB LED

  • Ameba x 1
  • WS2812B 4*4 RGB LED x 1


This example uses WS2812B4*4 RGB LED modules to light up LED colors. The libraries we need are:

Refer to the Arduino official website to install the library and add the .zip library to Ameba:

Except for VCC(3.3V) and GND, WS2812B only uses 1 DATA wire. The RTL8195 wiring diagram is shown below:


RTL8710 wiring diagram is shown below:


Open example “File” -> “Examples” -> “AmebaLedStrip” -> “WS2812Bdemo”, push “Reset” button after compiling and uploading to Ameba. Then you can find the effect of 5 lit LED on WS2812B.

Code Reference


Define Ameba signals output pin which is connected to WS2812B DATA IN. We define to D5 in this example.

#define NUM_LEDS  16

This example uses WS2812B 4*4 embedded 16 LED, and the parameter is defined to the number of LED on the module.

ws2812b ledstrip = ws2812b(DIGITALPINNUMBER , NUM_LEDS);

Initialize ws2812b. Construct Ameba signals output pin and the number of ws2812b LED.


ws2812b starts to operate.

ledstrip.setPixelColor(5,0,10,0); light up No.5 LED as green
ledstrip.setPixelColor(2,0,0,10); light up No.2 LED as blue
ledstrip.setPixelColor(1,10,10,10); light up No.1 LED as white
ledstrip.setPixelColor(3,10,0,0); light up No.3 LED as red
ledstrip.setPixelColor(8,10,0,0); light up No.8 LED as red

Use setPixelColor(index, Red, Green, Blue) to lit ws2812b LED. The LED number starts from No.0 and the LED numbers of the module are shown below.


Start to light up the specified LED.

Please confirm that QQ communication software is installed