Teach lesson
Arduino Visual Robot (4/4): marker-aware robot challenge
Students combine movement, sensors, markers, and reaction rules in a visual-programming robot challenge with documented test evidence.
Learning Outcomes
Use line sensors as evidence of light/dark surface reflectance.
Design a short reactive behaviour with input, decision, and output.
Evaluate a robot by evidence and explanation, not by perfect tracking.
Student activity preview
Activity Content
Preview only. In a class session, students can fill in responses and submit their work to the teacher.
Choose an achievable challenge
8 min
The robot's line sensors look at the surface and return a reflectance
reading: an approximate number from 0 to 2000. Light surfaces give
low values (near 0) and dark surfaces give high values (near 2000). A
threshold is the cut-off number you use to decide "light" or "dark". The
challenge is not to follow a perfect line, but to measure light/dark and program a
reaction.
Choose one challenge. All are valid if they use a sensor, a decision, and an observable output.
- Marker detector: when a dark mark is detected, stop and turn the red LED on.
- Patrol with warning: drive slowly and warn when a dark marker is detected.
- Careful robot: stop if there is either an obstacle or a marker.
- Surface traffic light: blue on light surface, red on dark surface, without moving.
You are not asked to follow a whole line. You are asked to explain what the robot detects and how it reacts.
Write your chosen challenge as a rule: "If the sensor detects..., then the robot...; otherwise, the robot...".
Calibrate light and dark
18 min
To see the reading you will use serial (a text channel from the robot to your
screen). If your lab does not show serial output, calibrate with the LED instead:
turn the red LED on when the reading is above your threshold and check whether it
tells a light surface apart from a dark one; adjust the threshold until it does.
Open the robot visual lab.
Set up serial communication.
In the main loop, use
Read line sensors.Read one sensor, such as
center,center-left, orcenter-right.Print the value to serial.
Observe one reading on a light surface and one reading on a dark area or visible marker.
Choose a threshold between the readings.
Calibration block image and text reference:
Before using messages:
[Setup] Serial speed 9600
In the main loop:
[Read line sensors]
[print]
center line-sensor value
or
center-left line-sensor value
or
center-right line-sensor value
[wait] 300 milliseconds
The read block must come before the individual sensor value. First measure light and dark; then choose your threshold.
Fill the table while you calibrate light and dark. Use at least two rows:
one light-surface row and one dark-surface or marker row. If you test an extra
marker position, add one more row; leave any remaining blank rows empty. In each
row, record the sensor position, surface, observed value, proposed threshold,
and your confidence.
| Sensor | Surface | Observed value (number or light/dark) | Proposed threshold | Confidence |
|---|---|---|---|---|
What threshold will you use to separate light and dark? Justify it using two readings from your table.
Build the behaviour
22 min
Build a minimum version of your challenge:
1. Read sensors.
2. Compare the reading with your threshold.
3. Activate a visible output: LED, serial message, and motors if appropriate.
4. Use a practical low speed such as 125 or 150, keep the movement short, and end with a stop if the robot moves.
Example marker detector:
- If center sensor > threshold: motors 0,0, red LED, message marker.
- Otherwise: blue LED and, optionally, a short forward movement at 125 or 150.
Marker detector block image and text reference:
In the main loop:
[Read line sensors]
if [center line-sensor value > threshold]:
[Change two motors speed]
Left: 0
Right: 0
[Set] red [led to] HIGH
[Set] blue [led to] LOW
[print] "marker"
else:
[Set] blue [led to] HIGH
[Set] red [led to] LOW
optional:
[Change two motors speed]
Left: 125
Right: 125
[wait] 300 milliseconds
[Change two motors speed]
Left: 0
Right: 0
This structure detects a marker or surface; it does not try to follow the whole line.
Describe one test that went well and one that should be improved. If you only ran one test, state what second test you would run.
Explain why your challenge does not depend on perfect line following. What concrete decision does the robot make from the sensor information?
Final submission
12 min
Final robot challenge
Submit:
1. Challenge name.
2. Main blocks used.
3. Threshold and calibration evidence.
4. Screenshot or description of the program.
5. Observed result from the robot test.
6. One concrete improvement.
What did you learn from programming a real robot that you would not learn from a simulation or from an Arduino board only?