3.7 Neopixel LEDs, LED matrix and Breathing Light
Learning Objectives:
After this lesson, students can
- understand the working principles of a LED matrix;
- write a program to turn a LED matrix into different patterns.
1. INTRODUCTION OF LED MATRIX
- NeoPixel LEDs are widely used these days in electronic projects, due to their attractive visual effects. These LEDs are available in various sizes and shapes and in the strip form.
After 1962, when the first LED was made and tested, this valuable piece became an inseparable part of our lives. In most electronic projects, you can find at least one single LED. Using the LEDs in different colors was so attractive that it caused the production of multi-color LEDs or RGB LEDs.

The RGB LED creates all the colors based on the three colors of red, green, and blue. For example, a red and green combination produces a yellow color. In this model, each color has a value between 0 and 255 for each red, green and blue colour components. For instance, these values are “255, 255, 0” (maximum red, maximum green, and minimum/no blue value) for yellow. RGB LEDs make a variety of colors based on this model.
Addressable LEDs
To control each RGB LED, you need 3 digital pins of a microcontroller (e.g. Arduino). For example, if you want to control an RGB LED string containing 64 LEDs, in order to control the color of each LED separately, you need 192 digital pins! So you have to forget controlling each LED individually or use LEDs that are addressable.
Addressable LEDs are a new generation of LEDs including a controller IC, in addition to RGB LEDs. This controller IC, usually WS2812, allows you to access multiple LEDs with a single digital pin by assigning an address to each LED and providing one wire communication. But unlike simple LEDs, these types of LEDs do not turn on only by applying voltage, they also require a microcontroller. NeoPixels are also available in the ring, strip, square and circular models and you can select the suitable model according to your project. NeoPixels are also chainable, so you can control multiple NeoPixels with only one signal wire and two wires for power (5V and GND).
Simulation:
The following ArduinoBlocks program is to implement the pattern in the above simulation.
Use Pin D5 for signaling.
2. CLASSWORK
Task: Turn on ALL LEDs into yellow (5 marks)
Change the above problem so that ALL the led pixels will be turned to YELLOW altogether at the same time.
In your program, the value for R, G, or B is limited by 20. Otherwise, the current may be too large so that the Wemos D1 board may be burnt.
PROJECT CODE:zKRVhUZx
Hints:- Do we need to use "Loop"? Can we just put the code in "Setup"?
- How can we change the colour to yellow? R = ?, G = ?, B = ?
- What are the purposes of the blocks "Set pixel # ..." and "Show"?
3. CLASSWORK / HOMEWORK
Task: Make a Breathing Light (5 marks)
PROJECT CODE:
ApZEvPUP
Off --> gradually ON (COLOUR) --> gradually Off
Repeat above.
The following partial program is a hint.
You may use your own way to write a program to get the required result.