Skip to content

Instantly share code, notes, and snippets.

@ChaunceyHoover
Last active February 18, 2018 01:45
Show Gist options
  • Save ChaunceyHoover/123320f231843d9f863ce700895d8781 to your computer and use it in GitHub Desktop.
Save ChaunceyHoover/123320f231843d9f863ce700895d8781 to your computer and use it in GitHub Desktop.
import time
import colorsys
import RPi.GPIO as GPIO
import Adafruit_WS2801
import Adafruit_GPIO.SPI as SPI
PIXEL_COUNT = 160
BRIGHTNESS = 0.05
SPI_PORT = 0
SPI_DEVICE = 0
pixels = Adafruit_WS2801.WS2801Pixels(PIXEL_COUNT, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE), gpio=GPIO)
if __name__ == "__main__":
pixels.clear()
# for i in range(150):
# pixels.set_pixel(i, Adafruit_WS2801.RGB_to_color(255, 0, 0))
# pixels.show()
offset = 0
while True:
offset = offset + 1
for i in range(PIXEL_COUNT):
r, g, b = colorsys.hsv_to_rgb(((i + offset) % 360) / 360.0, 1, 1)
pixels.set_pixel(i, Adafruit_WS2801.RGB_to_color(int(r * 255 * BRIGHTNESS), int(g * 255 * BRIGHTNESS), int(b * 255 * BRIGHTNESS)))
pixels.show()
time.sleep(0.01)
pixels.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment