Toggle Navigation
Hatchery
Eggs
Chinese Police Blink Pattern
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import color import utime import display import leds leds.dim_top(4) extra_left=12 extra_right=11 rng_h1=list(range(0,5))+[extra_left] rng_h2=list(range(6,11))+[extra_right] rng_q1=list(range(0,2))+[extra_left] rng_q2=list(range(2,5))+[] rng_q3=list(range(6,9))+[] rng_q4=list(range(9,11))+[extra_right] def ledsetrange(col,lst): for p in lst: leds.set(p,col) def blinkAlternating(step): step %= (21*2) leds.clear() if step % 2 == 1: return if step < 9*2: ledsetrange(color.RED,rng_h1) leds.set(extra_left,color.RED) ledsetrange(color.BLUE,rng_h2) leds.set(extra_right,color.BLUE) elif (step >= 9*2 and step < 11*2) or (step >= 13*2 and step < 15*2) or (step >= 17*2 and step < 19*2): ledsetrange(color.RED,rng_q1) leds.set(extra_left,color.RED) ledsetrange(color.BLUE,rng_q4) leds.set(extra_right,color.BLUE) elif (step >= 11*2 and step < 13*2) or (step >= 15*2 and step < 17*2) or (step >= 19*2 and step < 21*2): ledsetrange(color.RED,rng_q2) ledsetrange(color.BLUE,rng_q3) leds.update() with display.open() as disp: disp.clear() disp.backlight(0) disp.update() step=0 while True: blinkAlternating(step) step+=1 utime.sleep_ms(66)