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=OFF;1;0;2") ispis("P2=OFF;1;2;2") ispis("P4=OFF;1;4;2") while True: p1 = pin1.read_digital() p2 = pin2.read_digital() p4 = pin4.read_digital() #if p1 > 0 or p2 > 0 or p4 > 0: if p1 > 0: ispis("OFF;7;0;2;B") ispis("ON;7;0;2") music.pitch(1500, 50) sleep(200) ispis("ON;7;0;2;B") else: ispis("OFF;7;0;2") if p2 > 0: ispis("OFF;7;2;2;B") ispis("ON;7;2;2") music.pitch(1500, 50) sleep(200) ispis("ON;7;2;2;B") else: ispis("OFF;7;2;2") if p4 > 0: ispis("OFF;7;4;2;B") ispis("ON;7;4;2") music.pitch(1500, 50) sleep(200) ispis("ON;7;4;2;B") else: ispis("OFF;7;4;2")