Added new Python Scripts
This commit is contained in:
parent
321e99414d
commit
4de81692e2
146
13-dezember.py
Normal file
146
13-dezember.py
Normal file
@ -0,0 +1,146 @@
|
||||
import time
|
||||
from machine import Pin
|
||||
from neopixel import NeoPixel
|
||||
|
||||
#Define the strip pin number (28) and number of LEDs (15)
|
||||
strip = NeoPixel(Pin(28), 15)
|
||||
|
||||
sleep = (0.01)
|
||||
|
||||
i = 0
|
||||
green1 = 255
|
||||
green2 = 50
|
||||
green3 = 10
|
||||
green4 = 5
|
||||
green5 = 1
|
||||
|
||||
red1 = 0
|
||||
red2 = 0
|
||||
red3 = 0
|
||||
red4 = 0
|
||||
red5 = 0
|
||||
|
||||
blue1 = 255
|
||||
blue2 = 50
|
||||
blue3 = 10
|
||||
blue4 = 5
|
||||
blue5 = 1
|
||||
|
||||
|
||||
while True: # Run forever
|
||||
|
||||
while i < 14:
|
||||
if i == 0:
|
||||
strip.fill((0,0,0))
|
||||
strip[i] = (red1,green1,blue1)
|
||||
time.sleep(sleep)
|
||||
strip.write()
|
||||
i = i + 1
|
||||
strip.write()
|
||||
|
||||
elif i == 1:
|
||||
strip.fill((0,0,0))
|
||||
strip[i] = (red1,green1,blue1)
|
||||
time.sleep(sleep)
|
||||
strip[i-1] = (red2,green2,blue2)
|
||||
time.sleep(sleep)
|
||||
i = i + 1
|
||||
strip.write()
|
||||
|
||||
elif i == 2:
|
||||
strip.fill((0,0,0))
|
||||
strip[i] = (red1,green1,blue1)
|
||||
time.sleep(sleep)
|
||||
strip[i-1] = (red2,green2,blue2)
|
||||
time.sleep(sleep)
|
||||
strip[i-2] = (red3,green3,blue3)
|
||||
time.sleep(sleep)
|
||||
i = i + 1
|
||||
strip.write()
|
||||
|
||||
elif i == 3:
|
||||
strip.fill((0,0,0))
|
||||
strip[i] = (red1,green1,blue1)
|
||||
time.sleep(sleep)
|
||||
strip[i-1] = (red2,green2,blue2)
|
||||
time.sleep(sleep)
|
||||
strip[i-2] = (red3,green3,blue3)
|
||||
time.sleep(sleep)
|
||||
strip[i-3] = (red4,green4,blue4)
|
||||
time.sleep(sleep)
|
||||
i = i + 1
|
||||
strip.write()
|
||||
|
||||
elif i >= 4:
|
||||
strip.fill((0,0,0))
|
||||
strip[i] = (red1,green1,blue1)
|
||||
time.sleep(sleep)
|
||||
strip[i-1] = (red2,green2,blue2)
|
||||
time.sleep(sleep)
|
||||
strip[i-2] = (red3,green3,blue3)
|
||||
time.sleep(sleep)
|
||||
strip[i-3] = (red4,green4,blue4)
|
||||
time.sleep(sleep)
|
||||
strip[i-4] = (red5,green5,blue5)
|
||||
time.sleep(sleep)
|
||||
i = i + 1
|
||||
strip.write()
|
||||
|
||||
while i > 0:
|
||||
if i == 14:
|
||||
strip.fill((0,0,0))
|
||||
strip[i] = (red1,green1,blue1)
|
||||
time.sleep(sleep)
|
||||
i = i - 1
|
||||
strip.write()
|
||||
|
||||
elif i == 13:
|
||||
strip.fill((0,0,0))
|
||||
strip[i] = (red1,green1,blue1)
|
||||
time.sleep(sleep)
|
||||
strip[i+1] = (red2,green2,blue2)
|
||||
time.sleep(sleep)
|
||||
i = i - 1
|
||||
strip.write()
|
||||
|
||||
elif i == 12:
|
||||
strip.fill((0,0,0))
|
||||
strip[i] = (red1,green1,blue1)
|
||||
time.sleep(sleep)
|
||||
strip[i+1] = (red2,green2,blue2)
|
||||
time.sleep(sleep)
|
||||
strip[i+2] = (red3,green3,blue3)
|
||||
time.sleep(sleep)
|
||||
i = i - 1
|
||||
strip.write()
|
||||
|
||||
elif i == 11:
|
||||
strip.fill((0,0,0))
|
||||
strip[i] = (red1,green1,blue1)
|
||||
time.sleep(sleep)
|
||||
strip[i+1] = (red2,green2,blue2)
|
||||
time.sleep(sleep)
|
||||
strip[i+2] = (red3,green3,blue3)
|
||||
time.sleep(sleep)
|
||||
strip[i+3] = (red4,green4,blue4)
|
||||
time.sleep(sleep)
|
||||
i = i - 1
|
||||
strip.write()
|
||||
|
||||
elif i <= 10:
|
||||
|
||||
strip.fill((0,0,0))
|
||||
strip[i] = (red1,green1,blue1)
|
||||
time.sleep(sleep)
|
||||
strip[i+1] = (red2,green2,blue2)
|
||||
time.sleep(sleep)
|
||||
strip[i+2] = (red3,green3,blue3)
|
||||
time.sleep(sleep)
|
||||
strip[i+3] = (red4,green4,blue4)
|
||||
time.sleep(sleep)
|
||||
strip[i+4] = (red5,green5,blue5)
|
||||
time.sleep(sleep)
|
||||
i = i - 1
|
||||
strip.write()
|
||||
|
||||
|
57
14-dezember.py
Normal file
57
14-dezember.py
Normal file
@ -0,0 +1,57 @@
|
||||
# Imports
|
||||
import time
|
||||
from machine import Pin
|
||||
from neopixel import NeoPixel
|
||||
|
||||
# Define our button pin
|
||||
button = Pin(3, Pin.IN, Pin.PULL_DOWN)
|
||||
|
||||
# Define the strip pin number (28) and number of LEDs (15)
|
||||
strip = NeoPixel(Pin(28), 15)
|
||||
|
||||
# Colour variables
|
||||
red = 255,0,0
|
||||
green = 0,255,0
|
||||
blue = 0,0,255
|
||||
white = 255,255,255
|
||||
purple = 170,0,255
|
||||
yellow = 255,255,0
|
||||
|
||||
# Define colour list
|
||||
colours = [red, green, blue, white, purple, yellow]
|
||||
|
||||
# Create index variable starting at 0
|
||||
myindex = 0
|
||||
|
||||
# Variable with the number of items in our list (3)
|
||||
# We -1 as the index starts at 0, and we want to use this for the colour list index number (0, 1 or 2)
|
||||
# This is useful as it means we don't have to count the colours if we add more
|
||||
indexlength = len(colours) -1
|
||||
|
||||
while True: # Run forever
|
||||
|
||||
time.sleep(0.4) # Delay
|
||||
|
||||
if button() == 1: # If button pressed
|
||||
|
||||
# If the index variable is less than or equal to the lengh of the index
|
||||
if myindex < indexlength:
|
||||
|
||||
# Add +1 to the index variable
|
||||
myindex = myindex + 1
|
||||
|
||||
# If the index variable is over the index length
|
||||
else:
|
||||
|
||||
# Set index variable back to 0 (the first item in our list)
|
||||
myindex = 0
|
||||
|
||||
## Now this code runs AFTER the if statements...
|
||||
|
||||
# Fill the strip with the current list index colour
|
||||
strip.fill((colours[myindex]))
|
||||
|
||||
# Write the data to the LED strip
|
||||
strip.write()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user