from microbit import * import music display.off() # OK demo 04 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") p1p = 0 p2p = 0 p4p = 0 m1 = 0 m2 = 0 m4 = 0 m1p = 0 m2p = 0 m4p = 0 dj = 7 ispis("1:;0;0;G") ispis("2:;0;10;G") ispis("4:;0;20;G") while True: p1 = pin1.read_analog() - 100 p2 = pin2.read_analog() - 100 p4 = pin4.read_analog() - 100 m1 = p1 / dj m2 = p2 / dj m4 = p4 / dj if m1 != m1p: ispis("REC;10;0;"+str(m1p)+";8;B;B") ispis("REC;10;0;"+str(m1)+";8;C;C") m1p=m1 if m2 != m2p: ispis("REC;10;10;"+str(m2p)+";8;B;B") ispis("REC;10;10;"+str(m2)+";8;C;C") m2p=m2 if m4 != m4p: ispis("REC;10;20;"+str(m4p)+";8;B;B") ispis("REC;10;20;"+str(m4)+";8;C;C") m4p=m4