]>
vault307.fbx.one Git - random.git/blob - letITglowthread.py
1 from machine
import Pin
2 from neopixel
import NeoPixel
3 import time
, _thread
, random
10 seg5
= Pin(4, Pin
.OUT
)
11 seg6
= Pin(6, Pin
.OUT
)
13 # Create a list of our LEDs
14 segments
= [seg1
, seg2
, seg3
, seg4
, seg5
, seg6
]
17 greenbtn
= Pin(14, Pin
.IN
, Pin
.PULL_DOWN
)
18 redbtn
= Pin(15, Pin
.IN
, Pin
.PULL_DOWN
)
20 # Define the strip pin number (2) and number of LEDs (12)
21 ring
= NeoPixel(Pin(16), 12)
28 #r = random.randint(0,100)
29 #g = random.randint(0,100)
30 #b = random.randint(0,100)
34 # For loop to turn each LED on then off in order of the list
40 # For loop in reverse, running backwards through the list
41 for led
in reversed (segments
):
48 # Create random RGB values
49 r
= random
.randint(0,100)
50 g
= random
.randint(0,100)
51 b
= random
.randint(0,100)
55 # Light each LED a random colour
59 # Show the LED for this long
62 #Clear the ring at the end of each loop
67 if greenbtn
.value()==1:
68 _thread
.start_new_thread(colorRing(),())