More samples (#896)

* coast or brake

* fix title

* added lesson
This commit is contained in:
Peli de Halleux 2019-08-31 06:05:36 -07:00 committed by GitHub
parent 12b1eb349b
commit d5194b8d28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 1 deletions

BIN
docs/static/tutorials/coast-or-brake.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -0,0 +1,14 @@
# Coast Or Brake
```blocks
brick.buttonLeft.onEvent(ButtonEvent.Pressed, function () {
// tell motor to brake once the run command is done
motors.largeB.setBrake(true)
motors.largeB.run(100, 1, MoveUnit.Rotations)
})
brick.buttonRight.onEvent(ButtonEvent.Pressed, function () {
// tell motor to coast once the run command is done
motors.largeB.setBrake(false)
motors.largeB.run(100, 1, MoveUnit.Rotations)
})
```

View File

@ -33,6 +33,12 @@
"cardType": "example",
"url":"/tutorials/tank-zigzag",
"imageUrl":"/static/tutorials/tank-zigzag.png"
}, {
"name": "Coast Or Brake",
"description": "Tell motors to coast or brake once the run command is done.",
"cardType": "example",
"url":"/tutorials/coast-or-brake",
"imageUrl":"/static/tutorials/coast-or-brake.png"
}]
```
@ -43,3 +49,4 @@
[Pivot Turn](/tutorials/pivot-turn),
[Smooth Turn](/tutorials/smooth-turn),
[Tank ZigZag](/tutorials/tank-zigzag),
[Coast Or Brake](/tutorials/coast-or-brake)

View File

@ -0,0 +1,9 @@
# Pause Until Pressed
This is an example of code using a touch sensor to detect a wall or other obstacle. The motors are running until the sensor is pressed.
```blocks
motors.largeBC.tank(50, 50)
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
motors.largeBC.stop()
```

View File

@ -10,11 +10,17 @@
"url":"/tutorials/touch-to-run",
"imageUrl":"/static/tutorials/touch-to-run.png"
}, {
"name": "Touch Sensor Values",
"name": "Sensor Values",
"description": "Check the value of a Touch Sensor and stop a motor if pressed.",
"cardType": "tutorial",
"url":"/tutorials/touch-sensor-values",
"imageUrl":"/static/tutorials/touch-sensor-values.png"
},
"name": "Pause Until Pressed",
"description": "Waits for the sensor to be pressed before continuing the program",
"cardType": "tutorial",
"url":"/tutorials/pause-until-pressed",
"imageUrl":"/static/tutorials/pause-until-pressed.png"
}]
```
@ -22,3 +28,4 @@
[Touch to Run](/tutorials/touch-to-run),
[Touch Sensor Values](/tutorials/touch-sensor-values),
[Pause Until Pressed](/tutorials/pause-until-pressed)