from microbit import * import music display.off() # OK demo 01 sleep(2000) # -- COMMUNICATION - cannot be changed def ispis(tekst): dd = len(tekst) if dd < 31: salji(tekst) else: salji(tekst[0:30]+"+") salji(tekst[30:dd]) def salji(tekst): duz = len(tekst) buf = bytearray(duz) for n in range(0, duz): bb = ord(tekst[n:n+1]) buf[n] = bb try: i2c.write(0x11, buf) sleep(duz*8) # ok except OSError: print("er: salji") pin1.write_digital(0) pin2.write_digital(0) pin4.write_digital(0) ispis("CLS") ispis("P1=;1;0;2") ispis("P2=;1;2;2") ispis("P4=;1;4;2") p1p = 0 p2p = 0 p4p = 0 while True: p1 = pin1.read_analog() p2 = pin2.read_analog() p4 = pin4.read_analog() if p1 != p1p: ispis(str(p1p)+";7;0;2;B") ispis(str(p1)+";7;0;2") p1p=p1 if p2 != p2p: ispis(str(p2p)+";7;2;2;B") ispis(str(p2)+";7;2;2") p2p=p2 if p4 != p4p: ispis(str(p4p)+";7;4;2;B") ispis(str(p4)+";7;4;2") p4p=p4 sleep(50)