pxt-ev3/docs/coding/reverse-beeper-3.md

21 lines
462 B
Markdown
Raw Normal View History

2018-01-06 06:20:00 +01:00
# Reverse Beeper Activity 2
```blocks
let beep = false
beep = true
2018-01-23 23:52:41 +01:00
control.runInParallel(function () {
2018-02-19 16:35:08 +01:00
motors.largeBC.run(-20)
2018-01-06 06:20:00 +01:00
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear)
motors.largeBC.stop()
2018-01-06 06:20:00 +01:00
beep = false
})
2018-01-23 23:52:41 +01:00
control.runInParallel(function () {
2018-01-06 06:20:00 +01:00
while (beep) {
if (sensors.ultrasonic4.distance() < 20) {
music.playTone(440, sensors.ultrasonic4.distance())
pause(50)
2018-01-06 06:20:00 +01:00
}
}
})
```