You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/sensors.rst
+45-32Lines changed: 45 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,8 @@ Sensors tutorial
3
3
4
4
The GiggleBot comes with a couple of onboard sensors:
5
5
6
-
#. two light sensors, near the front eyes LEDs,
7
-
#. two line sensors, on the underside of the line follower.
6
+
#. Two light sensors, near the front eyes LEDs.
7
+
#. Two line sensors, on the underside of the line follower.
8
8
9
9
Light Sensors
10
10
-------------
@@ -37,19 +37,19 @@ your GiggleBot by using a flashlight.
37
37
38
38
This is how to use this project:
39
39
40
-
#. start GiggleBot and wait for sleepy face to appear on the Micro:Bit,
41
-
#. press button A to start the Chase the Light game (heart will replace the sleepy face),
42
-
#. chase the light as long as you want,
43
-
#. press button B to stop the GiggleBot and display sleepy face again.
40
+
#. Start GiggleBot and wait for sleepy face to appear on the Micro:Bit.
41
+
#. Press button A to start the Chase the Light game (heart will replace the sleepy face).
42
+
#. Chase the light as long as you want.
43
+
#. Press button B to stop the GiggleBot and display sleepy face again.
44
44
45
45
First, a bit of explanation on the algorithm being used here.
46
46
47
47
On starting the GiggleBot, the Micro:Bit will:
48
48
49
-
#. assign a value to the `diff` variable (here it is using 10),
50
-
#. display a sleepy face image,
51
-
#. resets whatever readings from the buttons it might have had,
52
-
#. then start a forever loop.
49
+
#. Assign a value to the `diff` variable (here it is using 10).
50
+
#. Display a sleepy face image.
51
+
#. Resets whatever readings from the buttons it might have had.
52
+
#. Start a forever loop.
53
53
54
54
This forever loop only waits for one thing:
55
55
for the user to press button A, and that's when the light chasing begins.
@@ -59,14 +59,14 @@ quite happy to be active! And then it starts a second forever loop! This second
59
59
forever loop is the actual Light Chasing game. It will end when button B is
60
60
pressed by the user.
61
61
62
-
How to chase a light:
62
+
How to Chase a Light:
63
63
64
-
#. take reading from both light sensors,
65
-
#. compare the readings, using `diff` to allow for small variations. You will most likely get absolutely identical readings, even if the light is mostly equal. Using a differential value helps stabilize the behavior. You can adapt to your own lighting conditions by changing this value.
66
-
#. if the right sensor reads more than the left sensor plus the `diff` value, then we know it's brighter to the right. Turn right.
67
-
#. if the left sensor reads more than the right sensor plus the `diff` value, then it's brighter to the left. Turn left.
68
-
#. if there isn't that much of a difference between the two sensors, go straight.
69
-
#. if button B gets pressed at any time, stop the robot, change sleepy face, and get out of this internal loop. The code will fall back to the first loop, ready for another game.
64
+
#. Take reading from both light sensors.
65
+
#. Compare the readings, using `diff` to allow for small variations. You will most likely get absolutely identical readings, even if the light is mostly equal. Using a differential value helps stabilize the behavior. You can adapt to your own lighting conditions by changing this value.
66
+
#. If the right sensor reads more than the left sensor plus the `diff` value, then we know it's brighter to the right. Turn right.
67
+
#. If the left sensor reads more than the right sensor plus the `diff` value, then it's brighter to the left. Turn left.
68
+
#. If there isn't that much of a difference between the two sensors, go straight.
69
+
#. If button B gets pressed at any time, stop the robot, change sleepy face, and get out of this internal loop. The code will fall back to the first loop, ready for another game.
70
70
71
71
72
72
@@ -132,17 +132,26 @@ It contains two line sensors. You can spot them from the top of the line
132
132
follower by two white dots. And from the bottom, they are identified as *R* and
0 commit comments