diff --git a/docs/static/tutorials/coast-or-brake.png b/docs/static/tutorials/coast-or-brake.png new file mode 100644 index 00000000..b5dbe19d Binary files /dev/null and b/docs/static/tutorials/coast-or-brake.png differ diff --git a/docs/static/tutorials/pause-until-pressed.png b/docs/static/tutorials/pause-until-pressed.png new file mode 100644 index 00000000..144c4307 Binary files /dev/null and b/docs/static/tutorials/pause-until-pressed.png differ diff --git a/docs/tutorials/coast-or-brake.md b/docs/tutorials/coast-or-brake.md new file mode 100644 index 00000000..145cd0e6 --- /dev/null +++ b/docs/tutorials/coast-or-brake.md @@ -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) +}) +``` \ No newline at end of file diff --git a/docs/tutorials/motors.md b/docs/tutorials/motors.md index 4b382eb5..e8e10d38 100644 --- a/docs/tutorials/motors.md +++ b/docs/tutorials/motors.md @@ -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) diff --git a/docs/tutorials/pause-until-pressed.md b/docs/tutorials/pause-until-pressed.md new file mode 100644 index 00000000..54e05aa7 --- /dev/null +++ b/docs/tutorials/pause-until-pressed.md @@ -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() +``` \ No newline at end of file diff --git a/docs/tutorials/touch-sensor.md b/docs/tutorials/touch-sensor.md index 9c96deaa..39a6e2f5 100644 --- a/docs/tutorials/touch-sensor.md +++ b/docs/tutorials/touch-sensor.md @@ -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) \ No newline at end of file