from microbit import * import music display.off() # OK demo 05 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") pin6.write_digital(0) pin16.write_digital(0) ispis("CLS") while True: p6 = pin6.read_digital() if p6 > 0: ispis("OFF;3;1;3;B") ispis("ON;3;1;3") ispis("BIP;260;200") # freq 0-500, len 0-1000 pin16.write_digital(1) sleep(200) ispis("ON;3;1;3;B") pin16.write_digital(0) else: ispis("OFF;3;1;3")