Toggle Navigation
Hatchery
Eggs
MyLights1
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import time, badge, sys valueindex = 1 lightarray = [0]*24 intensity = 255 direction = True # This function starts def setup(): vbatt = badge.battery_volt_sense() if (vbatt>4000): badge.leds_enable() badge.leds_send_data(bytes([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]), 24) time.sleep(2) badge.leds_send_data(bytes([32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0]), 24) time.sleep(2) badge.leds_send_data(bytes([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]), 24) else: badge.leds_disable() print("Badge battery low ("+str(vbatt)+" < 4000)...") while(1): vbatt = badge.battery_volt_sense() if (vbatt>4000): lightarray[valueindex]=intensity badge.leds_send_data(bytes(lightarray),24) lightarray[valueindex]=16 valueindexold=valueindex valueindex=valueindex+4 if direction else valueindex-4 if (direction and valueindexold != 1): valueindexold=valueindexold-4 else: if valueindexold != 21: valueindexold=valueindexold+4 lightarray[valueindexold]=0 if valueindex>=21: direction = False if valueindex==1: direction = True time.sleep_ms(50) else: sys.exit()