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

How to do it...

Let's have a look at how to do this:

  1. Make sure that the board is connected to your computer with a USB cable and that the CIRCUITPY drive appears.
  2. Save a text file on the drive with the following contents and name it main.py:
from adafruit_circuitplayground.express import cpx
import time

cpx.pixels[0] = (255, 0, 0) # set first NeoPixel to the color red
time.sleep(60)
  1. Once the file has been saved, eject the drive, and remove and reconnect the USB cable from the computer.
  2. The first NeoPixel on the drive should light up with a red color.
  3. Open the main.py file in your text editor of choice and change the cpx.pixels[0] line to cpx.pixels[1]. Save the file. This change will make the second NeoPixel light up instead of the first.
  4. Eject the drive, remove, and then reconnect the USB cable to see the change take effect.