Files
micromelon-website/content/resources/line-following.mdx
Tim Hadwen 1f8c46597b Site audit: fix broken images, add activity metadata, clean up content
- Remove broken image references from 25 MDX files (deleted spacer/content images)
- Add codingSkills and roverConcepts frontmatter to 24 activity pages
- Fix "Activity Demonstration" headings in 15 activity files (plain text -> h3)
- Remove unused "All" category from 89 MDX files
- Decode HTML entities (> <  ) in 9 content files
- Escape bare < > characters in MDX to fix build errors
- Standardize contact email to contact@micromelon.com.au
- Add missing description to rover-repair-request metadata
- Include previous session work: about-us updates, difficulty filtering,
  LearningPathway component, expanded schools list, new product/resource images

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 21:49:15 +10:00

49 lines
2.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Activity: Line Following"
date: "2022-02-23"
categories: ["Activities", "Simulator Activities"]
tags: ["Colour Sensors", "Branching", "Iteration", "Algorithm Design", "Intermediate"]
codingSkills: ["Branching", "Iteration", "Algorithm Design"]
roverConcepts: ["Colour"]
excerpt: "Learn the colour sensor and simple algorithm design while following the line."
featuredImage: "/images/resources/line-following.png"
---
Program the rover to follow a line. Use the colour sensors on the rover to help detect where the line is and determine where the rover should move and turn to stay on the line.
![](/images/content/055865-line-following.png)
### Activity Demonstration
### Setup
When setting up ensure that the line to be followed has a clear contrast from the surface it is on and is thick enough for the colour sensors to detect. We recommend a thickness of 1-2cm, anything less will become difficult for the rovers. When designing a track, try and use rounded corners for turns. The sharper the turn the more difficult it will be to stay on the line. You can also incorporate additional challenges into your course. For example, have rovers detect and go around objects on the track or detect different coloured lines that indicate speed changes or turning directions at intersections.
### Heres Our Approach
#### Stage 1
Add a while true loop and an ELSE/IF statement so that we can continuously ask our rover questions about its environment.
#### **Stage 2**
Now we need to add our brightness value that we are comparing to (in this case 210).
If you need to check the brightness value of your line, you can see the colour sensor values in the Sensor View of the Code Editor. Press the ROVER button in the top bar of the Code Editor. You can see the colour sensor values in the top right table of Sensor View.
#### **Stage 3**
Pick a brightness value between your line and the colour next to your line (e.g. if your sensor reads 130 for black, and 230 for white, something like 180 would be a good starting point). Then get the rover to drive gradually left or right using the set motor speeds block.
**Tip:**
Test with different numbers! In our example, a speed difference of 8 for the motors worked well, but numbers for your rover may vary. You could even experiment with different RGB values to see if that gives you a better result.
![](/images/content/3d0d0c-line-following-answer.png)
Example Code
![](/images/content/5b4ec0-line-following-sensor-view.png)
Sensor View in the Code Editor