Skip to content

Instantly share code, notes, and snippets.

@FoamyGuy
Created March 2, 2020 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FoamyGuy/7790404c30906a2ed23cff1bb3947c07 to your computer and use it in GitHub Desktop.
Save FoamyGuy/7790404c30906a2ed23cff1bb3947c07 to your computer and use it in GitHub Desktop.
# Crickit library demo - NeoPixel terminal
# Note: On CPX Crickit, NeoPixel pin is normally connected to A1, not to seesaw,
# so this demo would not control the NeoPixel terminal.
# On the Crickit FeatherWing, the NeoPixel terminal is controlled by seesaw.
# pylint can't figure out "pixel" can be indexed.
# pylint: disable=unsupported-assignment-operation
import time
from adafruit_crickit import crickit
PIXELS = 30
crickit.init_neopixel(PIXELS)
crickit.neopixel.fill(0)
# Assign to a variable to get a short name and to save time.
pixel = crickit.neopixel
colors = [
(100, 0, 0),
(0, 100, 0),
(0, 0, 100),
(100, 100, 100)
]
offset = 0
color = (75, 0, 100)
pixel.fill(color)
while True:
for i in range(100, -1, -1):
brightness = i / 100
pixel.brightness = brightness
pixel.fill(color)
# pixel.fill(tuple([int(i * brightness) for i in color]))
# pixel.show()
print(brightness)
time.sleep(0.05)
time.sleep(1)
for i in range(101):
brightness = i / 100
pixel.brightness = brightness
pixel.fill(color)
#pixel.fill(tuple([int(i * brightness) for i in color]))
# pixel.show()
print(brightness)
time.sleep(0.05)
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment