reverse beeper
This commit is contained in:
parent
6928f9e50e
commit
abeb378b17
@ -90,3 +90,25 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Reverse Bepper
|
||||||
|
|
||||||
|
```codecard
|
||||||
|
[{
|
||||||
|
"name": "Reverse Beeper",
|
||||||
|
"description": "Activity 1",
|
||||||
|
"url":"/coding/reverse-beeper-1",
|
||||||
|
"cardType": "example"
|
||||||
|
}, {
|
||||||
|
"name": "Reverse Beeper",
|
||||||
|
"description": "Activity 2",
|
||||||
|
"url":"/coding/reverse-beeper-2",
|
||||||
|
"cardType": "example"
|
||||||
|
}, {
|
||||||
|
"name": "Reverse Beeper",
|
||||||
|
"description": "Activity 3",
|
||||||
|
"url":"/coding/reverse-beeper-3",
|
||||||
|
"cardType": "example"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
11
docs/coding/reverse-beeper-1.md
Normal file
11
docs/coding/reverse-beeper-1.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Reverse Beeper Activity 1
|
||||||
|
|
||||||
|
```blocks
|
||||||
|
loops.forever(function () {
|
||||||
|
music.playTone(440, sensors.ultrasonic4.distance());
|
||||||
|
loops.pause(50)
|
||||||
|
})
|
||||||
|
motors.largeBC.setSpeed(-20);
|
||||||
|
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear);
|
||||||
|
motors.stopAllMotors();
|
||||||
|
```
|
13
docs/coding/reverse-beeper-2.md
Normal file
13
docs/coding/reverse-beeper-2.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# 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();
|
||||||
|
```
|
21
docs/coding/reverse-beeper-3.md
Normal file
21
docs/coding/reverse-beeper-3.md
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Reverse Beeper Activity 2
|
||||||
|
|
||||||
|
```blocks
|
||||||
|
let beep = false
|
||||||
|
beep = true
|
||||||
|
control.runInBackground(function () {
|
||||||
|
motors.largeB.setSpeed(-20)
|
||||||
|
motors.largeC.setSpeed(-20)
|
||||||
|
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear)
|
||||||
|
motors.stopAllMotors()
|
||||||
|
beep = false
|
||||||
|
})
|
||||||
|
control.runInBackground(function () {
|
||||||
|
while (beep) {
|
||||||
|
if (sensors.ultrasonic4.distance() < 20) {
|
||||||
|
music.playTone(440, sensors.ultrasonic4.distance())
|
||||||
|
loops.pause(50)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user