code.py
1 # SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries 2 # 3 # SPDX-License-Identifier: MIT 4 5 """ 6 NeoPixel example for Pico. Displays a rainbow on the NeoPixels. 7 8 REQUIRED HARDWARE: 9 * RGB NeoPixel LEDs connected to pin GP0. 10 """ 11 import time 12 import board 13 from rainbowio import colorwheel 14 import neopixel 15 16 # Update this to match the number of NeoPixel LEDs connected to your board. 17 num_pixels = 30 18 19 pixels = neopixel.NeoPixel(board.GP0, num_pixels, auto_write=False) 20 pixels.brightness = 0.5 21 22 23 def rainbow(speed): 24 for j in range(255): 25 for i in range(num_pixels): 26 pixel_index = (i * 256 // num_pixels) + j 27 pixels[i] = colorwheel(pixel_index & 255) 28 pixels.show() 29 time.sleep(speed) 30 31 32 while True: 33 rainbow(0)