From dd5e1957d585bff82f48cf9f48838469a82dbbd2 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Mon, 8 Jan 2018 14:06:29 -0800 Subject: [PATCH 1/2] fix coding page --- docs/coding.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/coding.md b/docs/coding.md index 67f75749..5a1fc342 100644 --- a/docs/coding.md +++ b/docs/coding.md @@ -167,4 +167,5 @@ "description": "Activity 2", "url":"/coding/roaming-2", "cardType": "example" -}, { +}] +``` From f4b78c3ee705a5c9c389213ca28fec996b0d3129 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Mon, 8 Jan 2018 14:06:39 -0800 Subject: [PATCH 2/2] PID example --- docs/examples/line-follower-pid.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 docs/examples/line-follower-pid.md diff --git a/docs/examples/line-follower-pid.md b/docs/examples/line-follower-pid.md new file mode 100644 index 00000000..fb8c5ca1 --- /dev/null +++ b/docs/examples/line-follower-pid.md @@ -0,0 +1,16 @@ + +```blocks +let lasterror = 0 +let D = 0 +let I = 0 +let P = 0 +let error = 0 +loops.forever(function () { + error = sensors.color3.light(LightIntensityMode.Reflected) - 35 + P = error * 5 + I = I + error * 0.01 + D = (error - lasterror) * 0.2 + motors.largeBC.steer(P + (I + D), 100) + lasterror = error +}) +``` \ No newline at end of file