pxt-ev3/docs/coding/reverse-beeper-2.md
2018-01-05 21:20:00 -08:00

14 lines
362 B
Markdown

# Reverse Beeper Activity 2
```blocks
loops.forever(function () {
if (motors.largeB.speed() != 0 && sensors.ultrasonic4.distance() < 20) {
music.playTone(440, sensors.ultrasonic4.distance());
loops.pause(50)
}
})
motors.largeBC.setSpeed(-20);
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear);
motors.stopAllMotors();
```