In [ ]:
import time
from dotstar import Adafruit_DotStar
In [ ]:
# Dotstar LEDs are designed for use in a LED strip and the software library reflects that
# so we'll make use of a strip of one LED
numpixels = 1
datapin = 23 # GPIO pin 23 is connected to the data channel of the LED
clockpin = 24 # GPIO pin 24 is connected to the clock channel of the LED
strip = Adafruit_DotStar(numpixels, datapin, clockpin)
strip.begin() # always call this before starting to use the LED
In [ ]:
# and we're ready to start!
# first we set the brightness of the LED(s) (max 255, so 127 is about 50%)
strip.setBrightness(127)
In [ ]:
pixel_index = 0 # Index of our first (and only) pixel
color_red = 0xFF0000 # Red
color_green = 0x0000FF # Green
color_blue = 0x00FF00 # Blue
In [ ]:
# configure color
strip.setPixelColor(pixel_index, color_blue)
# activate configuration
strip.show()
In [ ]:
color = color_red # make a color variable and store it in memory
while True: # repeat forever
strip.setPixelColor(pixel_index, color)
strip.show() # show color
time.sleep(0.5) # wait half a second
color >>= 8 # color cycle Red -> Green -> Blue -> Black
if(color == 0): color = 0xFF0000 # At black, start again at Red
# click the stop button (or choose Kernel > Interrupt from the menu) to stop the execution
In [ ]:
import colorsys
sat = 1
value = 0.5
length = 500
for teller in range(0, length + 1):
hue = teller/float(length)
color = list(colorsys.hsv_to_rgb(hue, sat, value))
intcolor = int(color[0]*256)*256**2 + int(color[1]*256)*256 + int(color[2]*256)
strip.setPixelColor(pixel_index, intcolor)
strip.show()
#time.sleep(1.0/length)
In [ ]:
import math
def makeColorGradient(frequency1, frequency2, frequency3, phase1, phase2, phase3, center=128, width=127, length=500):
for i in range(length):
rood = math.sin(frequency1*i + phase1) * width + center
groen = math.sin(frequency2*i + phase2) * width + center
blauw = math.sin(frequency3*i + phase3) * width + center
intcolor = int(rood) * 255**2 + int(groen) * 255 + int(blauw)
strip.setPixelColor(pixel_index, intcolor)
strip.show()
time.sleep(10.0/length)
print(makeColorGradient(.01,.01,.01,2,0,4))
In [ ]:
strip.setBrightness(0)
strip.show()