MicroPython
Jump to navigation
Jump to search
Projects
Red Hot
import random from machine import Pin from neopixel import NeoPixel from time import sleep_ms p = Pin(12, Pin.OUT) np = NeoPixel(p, 240) # Simple as possible while 1: np[random.randrange(0,240)] = (random.randrange(0,10),0,0) sleep_ms(10) np.write()
Iterations:
>>> def loop(r,s): ... np[random.randrange(0,240)] = (random.randrange(0,r),0,0) ... np.write() ... sleep_ms(s) ... >>> r,s=10,10 >>> np.fill((0,0,0)) >>> loop(10,10) >>> loop(10,10) >>> np.fill(0,0,0)def loop( >>> def loop(r,s): ... while 1: ... np[random.randrange(0,240)] = (random.randrange(0,r),0,0) ... np.write() ... sleep_ms(s) >>> def loop(r,s): ... while 1: ... blink(r) ... bork() ... np.write() ... sleep_ms(s) ... >>> def blink(r): ... np[random.randrange(0,240)] = (random.randrange(0,r),0,0) ... >>> def bork(): ... np[random.randrange(0,240)] = (0,0,0) ... np[random.randrange(0,240)] = (0,0,0) >>> loop(10,1) >>> def bork(): ... np[random.randrange(0,240)] = (0,0,0) ... np[random.randrange(0,240)] = (0,0,0) ... np[random.randrange(0,240)] = (0,0,0) ... np[random.randrange(0,240)] = (0,0,0) ...