traffic lights activity
This commit is contained in:
parent
931987468a
commit
6928f9e50e
@ -68,3 +68,25 @@
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## Traffic Lights
|
||||
|
||||
```codecard
|
||||
[{
|
||||
"name": "Traffic Lights",
|
||||
"description": "Activity 1",
|
||||
"url":"/coding/traffic-lights-1",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Traffic Lights",
|
||||
"description": "Activity 2",
|
||||
"url":"/coding/traffic-lights-2",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Traffic Lights",
|
||||
"description": "Activity 3",
|
||||
"url":"/coding/traffic-lights-3",
|
||||
"cardType": "example"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
9
docs/coding/traffic-lights-1.md
Normal file
9
docs/coding/traffic-lights-1.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Traffic Lights Activity 1
|
||||
|
||||
```blocks
|
||||
brick.buttonEnter.onEvent(ButtonEvent.Click, function () {
|
||||
motors.largeBC.tank(20, 20)
|
||||
sensors.color3.pauseForColor(ColorSensorColor.Red)
|
||||
motors.largeBC.tank(0, 0)
|
||||
})
|
||||
```
|
10
docs/coding/traffic-lights-2.md
Normal file
10
docs/coding/traffic-lights-2.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Traffic Lights Activity 2
|
||||
|
||||
```blocks
|
||||
sensors.color3.onColorDetected(ColorSensorColor.Red, function () {
|
||||
motors.largeBC.tank(0, 0)
|
||||
})
|
||||
sensors.color3.onColorDetected(ColorSensorColor.Green, function () {
|
||||
motors.largeBC.tank(20, 20)
|
||||
})
|
||||
```
|
11
docs/coding/traffic-lights-3.md
Normal file
11
docs/coding/traffic-lights-3.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Traffic Lights Activity 3
|
||||
|
||||
```blocks
|
||||
loops.forever(function () {
|
||||
if (sensors.color3.light(LightIntensityMode.Reflected) < 15) {
|
||||
motors.largeBC.tank(30, 12)
|
||||
} else {
|
||||
motors.largeBC.tank(12, 30)
|
||||
}
|
||||
})
|
||||
```
|
Loading…
Reference in New Issue
Block a user