SunFounder Thales Kit for Raspberry Pi Pico, Release 1.0
(continued from previous page)
self
.
buf[i]
=
value
Then, create a new file, and call the stored ws2812 library here.
import
machine
from
ws2812
import
WS2812
ws
=
WS2812(machine
.
Pin(
0
),
8
)
ws[
0
]
=
[
64
,
154
,
227
]
ws[
1
]
=
[
128
,
0
,
128
]
ws[
2
]
=
[
50
,
150
,
50
]
ws[
3
]
=
[
255
,
30
,
30
]
ws[
4
]
=
[
0
,
128
,
255
]
ws[
5
]
=
[
99
,
199
,
0
]
ws[
6
]
=
[
128
,
128
,
128
]
ws[
7
]
=
[
255
,
100
,
0
]
ws
.
write()
Let’s select some favorite colors and display them on the RGB LED Strip!
How it works?
In the ws2812 library, we have integrated related functions into the WS2812 class.
You can use the RGB LED Strip with the following statement.
from
ws2812
import
WS2812
Declare a WS2812 type object, named “ws”, it is connected to “pin”, there are “number” RGB LEDs on the WS2812
strip.
ws
=
WS2812(pin,number)
ws is an array object, each element corresponds to one RGB LED on the WS2812 strip, for example, ws[0] is the first
one, ws[7] is the eighth.
We can assign color values to each RGB LED, these values must be 24-bit color (represented with six hexadecimal
digits) or list of 3 8-bit RGB.
For example, the red value is “0xFF0000” or “[255,0,0]”.
ws[i]
=
color value
Then use this statement to write the color for the LED Strip and light it up.
ws
.
write()
You can also directly use the following statement to make all LEDs light up the same color.
ws
.
write_all(color value)
108
Chapter 3. For MicroPython User
Содержание Thales Kit
Страница 1: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 Jimmy SunFounder Jun 04 2021 ...
Страница 2: ......
Страница 4: ...ii ...
Страница 6: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 2 CONTENTS ...
Страница 10: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 6 Chapter 1 Introduction to Raspberry Pi Pico ...
Страница 12: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 8 Chapter 2 What is Included in This Kit ...
Страница 13: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 2 1 Components List 2 1 Components List 9 ...
Страница 42: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 38 Chapter 2 What is Included in This Kit ...
Страница 140: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 136 Chapter 3 For MicroPython User ...
Страница 164: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 160 Chapter 4 For Arduino User ...