2018-01-06 06:20:00 +01:00
|
|
|
# Reverse Beeper Activity 2
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
let beep = false
|
|
|
|
beep = true
|
|
|
|
control.runInBackground(function () {
|
2018-01-09 21:46:48 +01:00
|
|
|
motors.largeBC.setSpeed(-20)
|
2018-01-06 06:20:00 +01:00
|
|
|
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear)
|
2018-01-09 21:46:48 +01:00
|
|
|
motors.largeBC.stop()
|
2018-01-06 06:20:00 +01:00
|
|
|
beep = false
|
|
|
|
})
|
|
|
|
control.runInBackground(function () {
|
|
|
|
while (beep) {
|
|
|
|
if (sensors.ultrasonic4.distance() < 20) {
|
|
|
|
music.playTone(440, sensors.ultrasonic4.distance())
|
|
|
|
loops.pause(50)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
```
|