Add kitronic 6 and 9
This commit is contained in:
parent
0fba1b4819
commit
7eeb0a25a0
2 changed files with 36 additions and 0 deletions
|
@ -10,6 +10,7 @@ class Main:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._debounce = {BUTTON_A: False, BUTTON_B: False}
|
self._debounce = {BUTTON_A: False, BUTTON_B: False}
|
||||||
self._buttons = {BUTTON_A: button_a, BUTTON_B: button_b}
|
self._buttons = {BUTTON_A: button_a, BUTTON_B: button_b}
|
||||||
|
music.set_tempo(ticks=4, bpm=145)
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
while True:
|
while True:
|
||||||
|
|
35
kitronic_09.py
Normal file
35
kitronic_09.py
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
from microbit import *
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
while True:
|
||||||
|
charge = pin0.read_analog() / 10
|
||||||
|
if charge >= 95:
|
||||||
|
pin1.write_digital(1)
|
||||||
|
pin2.write_digital(1)
|
||||||
|
pin8.write_digital(1)
|
||||||
|
pin12.write_digital(1)
|
||||||
|
elif charge >= 75:
|
||||||
|
pin1.write_digital(1)
|
||||||
|
pin2.write_digital(1)
|
||||||
|
pin8.write_digital(1)
|
||||||
|
pin12.write_analog(int((charge - 75) / 25 * 1023))
|
||||||
|
elif charge >= 50:
|
||||||
|
pin1.write_digital(1)
|
||||||
|
pin2.write_digital(1)
|
||||||
|
pin8.write_analog(int((charge - 50) / 25 * 1023))
|
||||||
|
pin12.write_digital(0)
|
||||||
|
elif charge >= 25:
|
||||||
|
pin1.write_digital(1)
|
||||||
|
pin2.write_analog(int((charge - 25) / 25 * 1023))
|
||||||
|
pin8.write_digital(0)
|
||||||
|
pin12.write_digital(0)
|
||||||
|
else:
|
||||||
|
pin1.write_analog(int(charge / 25 * 1023))
|
||||||
|
pin2.write_digital(0)
|
||||||
|
pin8.write_digital(0)
|
||||||
|
pin12.write_digital(0)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in a new issue