Skip to content

Instantly share code, notes, and snippets.

@zocoi
Created February 8, 2019 00:50
Show Gist options
  • Save zocoi/35800ee77b6382eb8d9bcb0dbb337c60 to your computer and use it in GitHub Desktop.
Save zocoi/35800ee77b6382eb8d9bcb0dbb337c60 to your computer and use it in GitHub Desktop.
import time
import board
# For Trinket M0, Gemma M0, ItsyBitsy M0 Express and ItsyBitsy M4 Express
import adafruit_dotstar
led = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
def wheel(pos):
# Input a value 0 to 255 to get a color value.
# The colours are a transition r - g - b - back to r.
if pos < 0 or pos > 255:
return 0, 0, 0
if pos < 85:
return int(255 - pos * 3), int(pos * 3), 0
if pos < 170:
pos -= 85
return 0, int(255 - pos * 3), int(pos * 3)
pos -= 170
return int(pos * 3), 0, int(255 - (pos * 3))
led.brightness = 0.5
i = 0
while True:
i = (i + 1) % 256 # run from 0 to 255
led[0] = (wheel(i))
time.sleep(0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment