import time
import os
import microcontroller
import neopixel
import board
def cycleNeopixel(wait):
for r in range(255):
pixel[0] = (r, 0, 0)
time.sleep(wait)
for r in range(255, 0, -1):
pixel[0] = (r, 0, 0)
time.sleep(wait)
for g in range(255):
pixel[0] = (0, g, 0)
time.sleep(wait)
for g in range(255, 0, -1):
pixel[0] = (0, g, 0)
time.sleep(wait)
for b in range(255):
pixel[0] = (0, 0, b)
time.sleep(wait)
for b in range(255, 0, -1):
pixel[0] = (0, 0, b)
time.sleep(wait)
print("==============================")
print(os.uname())
print("Hello nanoESP32-S2/CircuitPython NeoPixel example")
print("cpu.temperature: " + str(microcontroller.cpu.temperature))
print()
print("neopixel version: " + neopixel.__version__)
print()
# Create the NeoPixel object
pixel = neopixel.NeoPixel(board.IO18, 1, pixel_order=neopixel.RGB)
pixel[0] = (0, 0, 0)
time.sleep(2.0)
cycleNeopixel(0.01)
pixel[0] = (0, 0, 0)
time.sleep(2.0)
print("- bye -\n")
It seem R and G is swapped in my unit, it should be GRB order for the build-in NeoPixel. To correct it, have to change "pixel_order=neopixel.RGB" to "pixel_order=neopixel.GRB" to match. It will be fixed in next exercise.