Need support? support.freenove.com
Chapter 3 Module test (necessary)
This function is of WS2812 library. When the LED color is set with the previous fuction, this function needs
to be executed to make the LED show the corresponding color. If the color is set, but this function is not
executed LED will not change color.
Generate rainbow colors in range of 0-255.
LED_TYPR(self,order,R_G_B)
Change the order in which the LED color data is transmitted. When the value of the order parameter is
"RGB", the order of data transmission should be: R-G-B; when the value of the order parameter is "GBR",
and the order of data transmission should be: G-B-R
theaterChaseRainbow(strip, wait_ms)
The function is used to make 8 LEDs show one color at the same time, and change to various colors to
make a blink. The blinking interval is wait_ms, and its default value is 50ms.
This function achieves the effect of rainbow breathing. It makes 8 LEDs display same color simultaneously,
and then change them all into various colors like breathing. The interval is wait_ms. The default value is
20ms.
rainbowCycle(strip, wait_ms)
This function also achieves the effect of rainbow breathing. but unlike rainbow(), it makes eight LEDs to
display different colors at the same time, and then change them into various color separately. The interval
is wait_ms. The default value is 20ms.
Result analysis
This code mainly achieves two LED effects, chasing animation and rainbow animation.
Chasing animation: first let the 8 LEDs light red one by one in turn, then green and blue. Interval is 50ms
between two LED, so the LED will display a round of red, then a round of green, and the last round of blue,
like chasing. Then let the LEDs blink with different colors with an interval of 50ms, rendering a tense
atmosphere, thus completing the chase animation.
Rainbow animation: The effect of the rainbow is different from the effect of blinking. The blinking is to make
the LED on, off, on, and off. And the rainbow is to make LED on all the time, and switch between different
colors, and the interval is shorter than the blinking. First, make the eight LEDs display one color at the same
time and then change the color with intervals of 20ms. And then make the eight LEDs display different colors
at the same time, and then change the color to produce another rainbow effect.