Skip to content

Commit 8eb3fb7

Browse files
authored
Merge pull request #143 from kattni/rainbowio-simpletest
Add rainbowio simpletest
2 parents f0a52b2 + b499010 commit 8eb3fb7

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SPDX-FileCopyrightText: 2022 ladyada for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
4+
import time
5+
import board
6+
from rainbowio import colorwheel
7+
import neopixel
8+
9+
NUMPIXELS = 12 # Update this to match the number of LEDs.
10+
SPEED = 0.05 # Increase to slow down the rainbow. Decrease to speed it up.
11+
BRIGHTNESS = 0.2 # A number between 0.0 and 1.0, where 0.0 is off, and 1.0 is max.
12+
PIN = board.A3 # This is the default pin on the 5x5 NeoPixel Grid BFF.
13+
14+
pixels = neopixel.NeoPixel(PIN, NUMPIXELS, brightness=BRIGHTNESS, auto_write=False)
15+
16+
17+
def rainbow_cycle(wait):
18+
for color in range(255):
19+
for pixel in range(len(pixels)): # pylint: disable=consider-using-enumerate
20+
pixel_index = (pixel * 256 // len(pixels)) + color * 5
21+
pixels[pixel] = colorwheel(pixel_index & 255)
22+
pixels.show()
23+
time.sleep(wait)
24+
25+
26+
while True:
27+
rainbow_cycle(SPEED)

0 commit comments

Comments
 (0)