7e9cc791ec
* Some edits for the new sensor/motor examples * article typo * dark and bright * fix block styling * I like 'on' * more block styling
16 lines
641 B
Markdown
16 lines
641 B
Markdown
# Coast or Brake
|
|
|
|
This code example will set the brake when button **A** is pressed or let the motor coast (turn freely when not running) when button **B** is pressed. The motor is turned by one rotation to cause motion.
|
|
|
|
```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)
|
|
})
|
|
``` |