Smart LEDs

Smart/Addressable LEDs

What are they?

Unlike common LEDs explained on our other page, Smart LEDs are LEDs with tiny microcontrollers on them. There are tons of different configurations of these LEDs from strips, matrixes or rings but they are all the same when coding them.

LED strip
LED Matrix
LED Ring

The two different strips supported by MakeCode Arcade are the “WS2812” or commonly known as Neopixels and the “APA102”. These refer to the chips on the LED strip.

How do you use them?

Whether you are using a Neopixel or APA102 led strip, you want to start with making a project in MakeCode Arcade. The difference is that Neopixel only requires one wire while APA102 strips require 2 wires. Neopixel can be almost any pin but for the APA strip, it has specific data and clock pins. P11 will always be the data pin and P12 will always be the clock pin. You will see this in the code example.

Wiring

3 wire for WS2812 / Neopixel strip
4 wires for APA102 strip

Wiring for both will be pretty simple. Both will require power and ground from the brainpad. For the 3 wire strip, you plug the remaining data wire into any of the P* pins, for example, P0.
Wiring for the 4 wire LED Strip depends on the board you have. If you are using Brainpad, you will put the Clock wire (usually labeled CI for Clock In) to P12 and the Data wire (usually labeled DI for Data In) to P11, along with power and ground.

Coding

Since MakeCode supports both strips, it will be pretty simple to control the LEDs, but you will have to add the extension for controlling the LEDs and the extension for the Pins, first. If you do not know how to add an extension to MakeCode, then read our article here.

If you do know, we are adding the “light” extension as well as the “edge connector” extension.

After adding the light extension, you can use the blocks under the “more” tab to light up your LEDs. Here is two examples, one with the 3 wire using a rainbow animation and the 4 wire using a gradient effect from blue to green fading from off, to bright.

Newsletter

Get Social
License
Creative Commons License
Except where otherwise noted, BrainPad provided material by GHI Electronic is licensed under a Creative Commons Attribution 4.0 International License.
Latest Press
December 19, 2019
October 11, 2019
September 26, 2019
August 23, 2019
August 7, 2019
August 5, 2019