Toggle Navigation
Hatchery
Eggs
LedQuest
__init__.py
Login
Register
__init__.py
Content
import samd, time, ugfx def clear_screen(): ugfx.clear(ugfx.BLACK) ugfx.flush() ugfx.clear(ugfx.WHITE) ugfx.flush() def msg(txt): clear_screen() ugfx.string(0, 0, txt, "pixelade13", ugfx.BLACK) ugfx.flush() def one_to_six(color, direction, delay): mr = 0 mg = 0 mb = 0 if color=="r": mr = 1 if color == "g": mg = 1 if color == "b": mb = 1 for i in range(6): if direction == "rtl": samd.led(5-i, mr, mg, mb) time.sleep(delay) samd.led(5-i, 0, 0, 0) else: samd.led(i, mr, mg, mb) time.sleep(delay) samd.led(i, 0, 0, 0) def xixao(): samd.led(0, 1, 0, 0) samd.led(1, 0, 1, 0) samd.led(2, 0, 0, 1) samd.led(3, 0, 0, 1) samd.led(4, 0, 1, 0) samd.led(5, 1, 0, 0) time.sleep(3) for i in range(6): samd.led(i, 0, 0, 0) def xixao2(): samd.led(0, 0, 0, 1) samd.led(1, 0, 1, 0) samd.led(2, 1, 0, 0) samd.led(3, 1, 0, 0) samd.led(4, 0, 1, 0) samd.led(5, 0, 0, 1) time.sleep(3) for i in range(6): samd.led(i, 0, 0, 0) def i_will_leave_the_light_on(): for i in range(6): samd.led(i, 1, 1, 1) def main(): ugfx.init() clear_screen() msg("LED test") time.sleep(3) msg("Red slow...") one_to_six("r","ltr", 1) time.sleep(3) msg("Green bck..") one_to_six("g","rtl", 1) time.sleep(3) msg("Faster.....") one_to_six("b","ltr", 0.5) time.sleep(3) msg("Slower.....") one_to_six("b","rtl", 2) time.sleep(3) one_to_six("r","ltr", 0.1) one_to_six("g","ltr", 0.1) one_to_six("b","ltr", 0.1) one_to_six("r","rtl", 0.1) one_to_six("g","rtl", 0.1) one_to_six("b","rtl", 0.1) msg("Just xixao :)") xixao() time.sleep(1) xixao2() time.sleep(3) clear_screen() msg("I wlil levae d lght 1") i_will_leave_the_light_on() time.sleep(5) for i in range(6): samd.led(i, 0, 0, 0) msg("Bye") main()