Add 'red light, green light' tutorial (#436)
This commit is contained in:
parent
57c1ae0f99
commit
e11b11d19c
BIN
docs/static/tutorials/redlight-greenlight.png
vendored
Normal file
BIN
docs/static/tutorials/redlight-greenlight.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
BIN
docs/static/tutorials/redlight-greenlight/pause-color-sensor-dropdown.PNG
vendored
Normal file
BIN
docs/static/tutorials/redlight-greenlight/pause-color-sensor-dropdown.PNG
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.8 KiB |
BIN
docs/static/tutorials/redlight-greenlight/redlight-greenlight.gif
vendored
Normal file
BIN
docs/static/tutorials/redlight-greenlight/redlight-greenlight.gif
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 477 KiB |
@ -60,5 +60,11 @@ Step by step guides to coding your @boardname@.
|
||||
"cardType": "tutorial",
|
||||
"url":"/tutorials/line-following",
|
||||
"imageUrl":"/static/tutorials/line-following.png"
|
||||
}, {
|
||||
"name": "Red Light, Green Light",
|
||||
"description": "Play Red Light, Green Light using the Color sensor and the robot.",
|
||||
"cardType": "tutorial",
|
||||
"url":"/tutorials/redlight-greenlight",
|
||||
"imageUrl":"/static/tutorials/redlight-greenlight.png"
|
||||
}]
|
||||
```
|
62
docs/tutorials/redlight-greenlight.md
Normal file
62
docs/tutorials/redlight-greenlight.md
Normal file
@ -0,0 +1,62 @@
|
||||
# Red Light, Green Light
|
||||
|
||||
## Introduction @fullscreen
|
||||
|
||||
Use the ``||sensors:pause color sensor||`` block to play Red Light, Green Light with your @boardname@ robot!
|
||||
|
||||
![Brick simulation with color sensor and motors](/static/tutorials/redlight-greenlight/redlight-greenlight.gif)
|
||||
|
||||
## Step 1
|
||||
|
||||
Open the ``||sensors:Sensors||`` Toolbox drawer. Drag out **2** ``||sensors:pause color sensor||`` blocks onto the Workspace, and drop them into the ``||loops:forever||`` loop.
|
||||
|
||||
```blocks
|
||||
forever(function () {
|
||||
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Blue)
|
||||
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Blue)
|
||||
})
|
||||
```
|
||||
|
||||
## Step 2
|
||||
|
||||
In the first ``||sensors:pause color sensor||`` block, use the second drop-down menu to select the "Green" color. In the second ``||sensors:pause color sensor||`` block, use the second drop-down menu to select the "Red" color.
|
||||
|
||||
![Color selection dropdown](/static/tutorials/redlight-greenlight/pause-color-sensor-dropdown.png)
|
||||
|
||||
```blocks
|
||||
forever(function () {
|
||||
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Green)
|
||||
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
|
||||
})
|
||||
```
|
||||
|
||||
## Step 3
|
||||
|
||||
Open the ``||motors:Motors||`` Toolbox drawer. Drag out a ``||motors:tank large motors||`` block onto the Workspace, and drop in between the ``||sensors:pause color sensor||`` blocks.
|
||||
|
||||
```blocks
|
||||
forever(function () {
|
||||
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Green)
|
||||
motors.largeBC.tank(50, 50)
|
||||
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
|
||||
})
|
||||
```
|
||||
|
||||
## Step 4
|
||||
|
||||
Open the ``||motors:Motors||`` Toolbox drawer. Drag out a ``||motors:stop all motors||`` block onto the Workspace, and drop it in after the second ``||sensors:pause color sensor||`` block in the ``||loops:forever||`` loop.
|
||||
|
||||
```blocks
|
||||
forever(function () {
|
||||
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Green)
|
||||
motors.largeBC.tank(50, 50)
|
||||
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
|
||||
motors.stopAll()
|
||||
})
|
||||
```
|
||||
|
||||
## Step 5
|
||||
|
||||
Now, plug your @boardname@ into the computer with the USB cable, and click the **Download** button at the bottom of your screen. Follow the directions to save your program to the brick.
|
||||
|
||||
Attach a Color Sensor to Port 3 of your brick, and attach your brick to a driving base with large motors attached to Ports B and C. See the building instructions for: _Driving Base with Color Sensor Forward_. Test your program by putting a green or red piece of paper or LEGO brick in front of the color sensor.
|
Loading…
Reference in New Issue
Block a user