Teach the robot to follow a path autonomously!
How infrared sensors detect black vs white surfaces
Making decisions based on sensor data
Robot makes decisions without human control
Fine-tuning sensor sensitivity for accuracy
Before coding, create a simple track using black tape on a light floor:
Flip the Maqueen upside down. See the two small sensors near the front? These are infrared line sensors. They shine invisible light downward and measure how much reflects back. Black absorbs light (low reading), white reflects (high reading).
In MakeCode, create a test program to see what the sensors detect:
Hold the robot over your black tape. The arrows show which sensor sees black!
Here's the strategy: The robot tries to keep the line between its two sensors. When it drifts, it corrects by turning!
Here's the complete line-following program:
Upload the code and place the robot on your track with the line between the sensors. Power it on and watch it go!
Once the basic line works, try these challenges:
The infrared sensors emit light at 940nm wavelength (invisible to humans). When this light hits a black surface, most photons are absorbed. White surfaces reflect them back to a photodetector in the sensor. The micro:bit reads this as a digital signal: HIGH (white) or LOW (black).
The program runs this check loop about 100 times per second—so even at full speed, the robot constantly adjusts its path!
Real-World Connection: This is exactly how warehouse robots, automated vacuums (Roomba), and self-driving cars stay on course. They use sensors + decision logic to navigate autonomously! 🚗🤖
Awesome work! The robot now makes autonomous decisions using sensor feedback. This is real robotics! The boys learned about sensors, conditional logic, and calibration—skills used in Mars rovers and factory automation!
Keep experimenting: Can they design a race track with lap counting? Or add obstacles that it must navigate around while following the line?
Next Mission: Obstacle Avoider 🚧 →