上QQ阅读APP看书,第一时间看更新
How to do it...
To do this, perform the following steps:
- Run the following lines of code in the REPL:
>>> from adafruit_circuitplayground.express import cpx >>> RGB = dict(black=0x000000, blue=0x0000FF, green=0x00FF00,
... cyan=0x00FFFF, ... red=0xFF0000, magenta=0xFF00FF, yellow=0xFFFF00,
... white=0xFFFFFF) >>> cpx.pixels[0] = RGB['red']
- You should see the first NeoPixel turn red.
- Use the following code to set the first eight pixels to one of the named colors in alphabetical order:
>>> for i, name in enumerate(sorted(RGB)): ... cpx.pixels[i] = RGB[name]