MicroPython Cookbook
上QQ阅读APP看书,第一时间看更新

How to do it...

To do this, perform the following steps:

  1. Run the following lines of code in the REPL:
>>> from adafruit_circuitplayground.express import cpx
>>> cpx.pixels[0] = (255, 0, 0)
  1. Now, you should see the first NeoPixel turn red.
  2. When you run the following code, you should see the first NeoPixel turn green:
>>> cpx.pixels[0] = (0, 255, 0)
  1. When you run the following code, you should see the first NeoPixel turn blue:
>>> cpx.pixels[0] = (0, 0, 255)
  1. The following code should retrieve the current color value of the first NeoPixel:
>>> cpx.pixels[0]
(0, 0, 255)
  1. Run the following code to turn off the first NeoPixel:
>>> cpx.pixels[0] = (0, 0, 0)
  1. Run the following code and the second NeoPixel should turn red:
>>> cpx.pixels[1] = (255, 0, 0)