def on_forever(): serial.write_line("" + str((minibit.sonar(mbPingUnit.CENTIMETERS)))) basic.pause(100) basic.forever(on_forever)