From 6928f9e50e8ffc6ec734b06ceeac26b33a96767d Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 5 Jan 2018 19:28:24 -0800 Subject: [PATCH] traffic lights activity --- docs/coding.md | 22 ++++++++++++++++++++++ docs/coding/traffic-lights-1.md | 9 +++++++++ docs/coding/traffic-lights-2.md | 10 ++++++++++ docs/coding/traffic-lights-3.md | 11 +++++++++++ 4 files changed, 52 insertions(+) create mode 100644 docs/coding/traffic-lights-1.md create mode 100644 docs/coding/traffic-lights-2.md create mode 100644 docs/coding/traffic-lights-3.md diff --git a/docs/coding.md b/docs/coding.md index 507c6b15..f5a428ec 100644 --- a/docs/coding.md +++ b/docs/coding.md @@ -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" +} +] +``` diff --git a/docs/coding/traffic-lights-1.md b/docs/coding/traffic-lights-1.md new file mode 100644 index 00000000..588253a9 --- /dev/null +++ b/docs/coding/traffic-lights-1.md @@ -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) +}) +``` \ No newline at end of file diff --git a/docs/coding/traffic-lights-2.md b/docs/coding/traffic-lights-2.md new file mode 100644 index 00000000..d1a08320 --- /dev/null +++ b/docs/coding/traffic-lights-2.md @@ -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) +}) +``` \ No newline at end of file diff --git a/docs/coding/traffic-lights-3.md b/docs/coding/traffic-lights-3.md new file mode 100644 index 00000000..b10b786f --- /dev/null +++ b/docs/coding/traffic-lights-3.md @@ -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) + } +}) +``` \ No newline at end of file