Вот пример:
Код:
def on_forever(): if maqueen.ultrasonic(PingUnit.CENTIMETERS) < 30 and maqueen.ultrasonic(PingUnit.CENTIMETERS) != 0: maqueen.motor_run(maqueen.Motors.M1, maqueen.Dir.CCW, 40) maqueen.motor_run(maqueen.Motors.M2, maqueen.Dir.CCW, 40) music.play_tone(Note.C, music.beat(BeatFraction.WHOLE)) maqueen.write_led(maqueen.LED.LED_LEFT, maqueen.LEDswitch.TURN_OFF) maqueen.write_led(maqueen.LED.LED_RIGHT, maqueen.LEDswitch.TURN_OFF) elif maqueen.ultrasonic(PingUnit.CENTIMETERS) > 30 and maqueen.ultrasonic(PingUnit.CENTIMETERS) != 0: maqueen.motor_run(maqueen.Motors.M1, maqueen.Dir.CW, 40) maqueen.motor_run(maqueen.Motors.M2, maqueen.Dir.CW, 40) maqueen.write_led(maqueen.LED.LED_LEFT, maqueen.LEDswitch.TURN_ON) maqueen.write_led(maqueen.LED.LED_RIGHT, maqueen.LEDswitch.TURN_ON) basic.forever(on_forever)