MicroPython
Jump to navigation
Jump to search
Projects
Red Hot
main.py
import random
from machine import Pin
from neopixel import NeoPixel
from time import sleep_ms
r,s=10,10
p=Pin(12,Pin.OUT)
np=NeoPixel(p,240)
def simple():
# Simple as possible
while 1:
np[random.randrange(0,240)]=(random.randrange(0,10),0,0)
sleep_ms(10)
np.write()
#simple()
def loop(r,s):
np.fill((0,2,8))
while 1:
#Upper red sparks
blink(r)
bork()
#Base burning
base(10,30,0,12)
np.write()
sleep_ms(s)
def base(redMin,redMax,grnMin,grnMax):
for i in range(53,150):
np[i]=(random.randrange(redMin,redMax),random.randrange(grnMin,grnMax),0)
def blink(r):
np[random.randrange(150,240)]=(random.randrange(0,r),0,0)
def bork():
np[random.randrange(180,240)]=(0,0,0)
np[random.randrange(210,240)]=(0,0,0)
np[random.randrange(220,240)]=(0,0,0)
np[random.randrange(220,240)]=(0,0,0)
print("Blinker for WS2812b RGBx240 strip")
print("loop(r,s) #Intensity[2-256],Delay(ms)")
print("simple() #Alternative random one-liner")
loop(66,10)