From b4990109ef563d41b0dc799e91e9d1705f9525e9 Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Fri, 18 Nov 2022 15:10:20 -0500 Subject: [PATCH] Add rainbowio simpletest --- examples/neopixel_rainbowio_simpletest.py | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 examples/neopixel_rainbowio_simpletest.py diff --git a/examples/neopixel_rainbowio_simpletest.py b/examples/neopixel_rainbowio_simpletest.py new file mode 100644 index 0000000..a3e6a81 --- /dev/null +++ b/examples/neopixel_rainbowio_simpletest.py @@ -0,0 +1,27 @@ +# SPDX-FileCopyrightText: 2022 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT + +import time +import board +from rainbowio import colorwheel +import neopixel + +NUMPIXELS = 12 # Update this to match the number of LEDs. +SPEED = 0.05 # Increase to slow down the rainbow. Decrease to speed it up. +BRIGHTNESS = 0.2 # A number between 0.0 and 1.0, where 0.0 is off, and 1.0 is max. +PIN = board.A3 # This is the default pin on the 5x5 NeoPixel Grid BFF. + +pixels = neopixel.NeoPixel(PIN, NUMPIXELS, brightness=BRIGHTNESS, auto_write=False) + + +def rainbow_cycle(wait): + for color in range(255): + for pixel in range(len(pixels)): # pylint: disable=consider-using-enumerate + pixel_index = (pixel * 256 // len(pixels)) + color * 5 + pixels[pixel] = colorwheel(pixel_index & 255) + pixels.show() + time.sleep(wait) + + +while True: + rainbow_cycle(SPEED)