diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index a27cf9d6..8681d895 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -19,11 +19,14 @@ * [What Animal Am I?](/tutorials/what-animal-am-i) * [Music Brick](/tutorials/music-brick) * [Run Motors](/tutorials/run-motors) + * [Tank ZigZag](/tutorials/tank-zigzag) * [Touch to Run](/tutorials/touch-to-run) * [Touch Sensor Values](/tutorials/touch-sensor-values) * [What Color?](/tutorials/what-color) * [Line Following](/tutorials/line-following) * [Red Light, Green Light](/tutorials/redlight-greenlight) + * [Reflected Light Measure](/tutorials/reflected-light-measure) + * [Reflected Light Calibration](/tutorials/reflected-light-calibration) * [Object Near?](/tutorials/object-near) * [Security Alert](/tutorials/security-alert) diff --git a/docs/static/tutorials/reflected-light-calibration.png b/docs/static/tutorials/reflected-light-calibration.png new file mode 100644 index 00000000..f4883093 Binary files /dev/null and b/docs/static/tutorials/reflected-light-calibration.png differ diff --git a/docs/static/tutorials/reflected-light-measure.png b/docs/static/tutorials/reflected-light-measure.png new file mode 100644 index 00000000..66fb98d2 Binary files /dev/null and b/docs/static/tutorials/reflected-light-measure.png differ diff --git a/docs/static/tutorials/tank-zigzag.png b/docs/static/tutorials/tank-zigzag.png new file mode 100644 index 00000000..6a70f473 Binary files /dev/null and b/docs/static/tutorials/tank-zigzag.png differ diff --git a/docs/tutorials/color-sensor.md b/docs/tutorials/color-sensor.md index 42c5efb4..2caf8f1d 100644 --- a/docs/tutorials/color-sensor.md +++ b/docs/tutorials/color-sensor.md @@ -21,6 +21,18 @@ "cardType": "tutorial", "url":"/tutorials/redlight-greenlight", "imageUrl":"/static/tutorials/redlight-greenlight.png" +}, { + "name": "Reflected Light Measure", + "description": "Teach the sensor what light or dark is.", + "cardType": "example", + "url":"/tutorials/reflected-light-measure", + "imageUrl":"/static/tutorials/reflected-light-measure.png" +}, { + "name": "Reflected Light Calibration", + "description": "Use the auto-calibration feature to setup the dark and bright values.", + "cardType": "example", + "url":"/tutorials/reflected-light-calibration", + "imageUrl":"/static/tutorials/reflected-light-calibration.png" }] ``` diff --git a/docs/tutorials/motors.md b/docs/tutorials/motors.md index 32e180de..7607bb95 100644 --- a/docs/tutorials/motors.md +++ b/docs/tutorials/motors.md @@ -9,6 +9,12 @@ "cardType": "tutorial", "url":"/tutorials/run-motors", "imageUrl":"/static/tutorials/run-motors.png" +}, { + "name": "Tank ZigZag", + "description": "Use the tank block to keep motors in sync.", + "cardType": "example", + "url":"/tutorials/tank-zigzag", + "imageUrl":"/static/tutorials/tank-zigzag.png" }] ``` diff --git a/docs/tutorials/reflected-light-calibration.md b/docs/tutorials/reflected-light-calibration.md new file mode 100644 index 00000000..4bca31dd --- /dev/null +++ b/docs/tutorials/reflected-light-calibration.md @@ -0,0 +1,24 @@ +# Reflected light calibration + +The ``calibrateLight`` blocks allows you to calibrate the reflected light of the color sensor in one block. Start the block and move the sensor over the dark and bright surface; then stop moving it. + +```blocks +sensors.color3.onLightDetected(LightIntensityMode.Reflected, Light.Dark, function () { + brick.showString("dark", 2) +}) +sensors.color3.onLightDetected(LightIntensityMode.Reflected, Light.Bright, function () { + brick.showString("bright", 2) +}) +console.sendToScreen() +console.log("move color sensor") +console.log("over DARK and BRIGHT color") +console.log("and stop moving when done") +console.log("press ENTER when ready") +brick.buttonEnter.pauseUntil(ButtonEvent.Pressed) +sensors.color3.calibrateLight(LightIntensityMode.Reflected) +brick.showValue("dark", sensors.color3.threshold(Light.Dark), 4) +brick.showValue("bright", sensors.color3.threshold(Light.Bright), 5) +forever(function () { + brick.showValue("reflected light", sensors.color3.light(LightIntensityMode.Reflected), 1) +}) +``` \ No newline at end of file diff --git a/docs/tutorials/reflected-light-measure.md b/docs/tutorials/reflected-light-measure.md new file mode 100644 index 00000000..8a4a6148 --- /dev/null +++ b/docs/tutorials/reflected-light-measure.md @@ -0,0 +1,29 @@ +# Reflected light measure + +This example uses a color sensor to measure the reflected light on the dark and light surface +and set the light/dark thresholds. + +```blocks +sensors.color3.onLightDetected(LightIntensityMode.Reflected, Light.Dark, function () { + brick.showString("dark", 2) +}) +sensors.color3.onLightDetected(LightIntensityMode.Reflected, Light.Bright, function () { + brick.showString("bright", 2) +}) +console.sendToScreen() +console.log("move color sensor") +console.log("over DARK color") +console.log("press ENTER when ready") +brick.buttonEnter.pauseUntil(ButtonEvent.Pressed) +sensors.color3.setThreshold(Light.Dark, sensors.color3.light(LightIntensityMode.Reflected) + 5) +console.logValue("dark", sensors.color3.threshold(Light.Dark)) +console.log("move color sensor") +console.log("over BRIGHT color") +console.log("press ENTER when ready") +brick.buttonEnter.pauseUntil(ButtonEvent.Pressed) +sensors.color3.setThreshold(Light.Bright, sensors.color3.light(LightIntensityMode.Reflected) - 5) +console.logValue("bright", sensors.color3.threshold(Light.Bright)) +forever(function () { + brick.showValue("reflected light", sensors.color3.light(LightIntensityMode.Reflected), 1) +}) +``` \ No newline at end of file diff --git a/docs/tutorials/tank-zigzag.md b/docs/tutorials/tank-zigzag.md new file mode 100644 index 00000000..36c535d4 --- /dev/null +++ b/docs/tutorials/tank-zigzag.md @@ -0,0 +1,17 @@ +# Tank ZigZag + +This example shows how to use the [tank](/reference/motors/tank) block to keep the speed of 2 large motors synchronized. In this example, a [EV3 Driving Base](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-rem-driving-base-79bebfc16bd491186ea9c9069842155e.pdf) +) will move on a zig zag pattern. + +```blocks +/** + * Use the tank block to keep large motors synched. + Use this code with a EV3 driving base. + */ +forever(function () { + brick.showImage(images.eyesMiddleRight) + motors.largeBC.tank(50, 10, 2, MoveUnit.Rotations) + brick.showImage(images.eyesMiddleLeft) + motors.largeBC.tank(10, 50, 2, MoveUnit.Rotations) +}) +``` \ No newline at end of file