]> vault307.fbx.one Git - random.git/blob - ledStranRAND.py
different projects to learn new things
[random.git] / ledStranRAND.py
1 # Imports
2 from machine import Pin
3 from neopixel import NeoPixel
4 import time, random
5
6 # LED details
7 GPIOnumber = 28
8 LEDcount = 15
9
10 # Define the strand pin number and number of LEDs from variables
11 strand = NeoPixel(Pin(GPIOnumber), LEDcount)
12
13 # Turn off all LEDs before program start
14 strand.fill((0,0,0))
15 strand.write()
16 time.sleep(1)
17
18 while True:
19 mycolour = random.randint(0,256),random.randint(0,256),random.randint(0,256)
20
21 for i in range(LEDcount):
22
23 strand[i] = (mycolour)
24 strand.write()
25
26 # Show the light for this long
27 time.sleep(.09)
28
29 #Clear the strand at the end of each loop
30 strand.fill((0,0,0))
31 strand.write()
32
33 for i in reversed (range(LEDcount)):
34 strand[i] =(mycolour)
35 strand.write()
36
37 # Show the light for this long
38 time.sleep(.09)
39
40 #Clear the strand at the end of each loop
41 strand.fill((0,0,0))
42 strand.write()