Files
micromelon-website/content/resources/stop-on-colour-change.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.1 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: Stop On Colour Change"
date: "2021-06-03"
categories: ["Activities"]
tags: ["Colour Sensors", "Branching", "Iteration"]
codingSkills: ["Branching", "Iteration"]
roverConcepts: ["Colour"]
excerpt: "Learn branching, iteration, and how to use the colour sensors."
featuredImage: "/images/resources/stop-on-colour-change.png"
---
Program the rover to keep moving forward until it detects a change of floor colour with the colour sensors. Once it detects this colour, stop the rover.
### Activity Demonstration
<iframe width="560" height="315" src="https://www.youtube.com/embed/HJSQU3Jaar8" title="Stop on Colour Change Activity Demonstration" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen></iframe>
### Setup
For this exercise we recommend a strip of tape stuck to the floor that contrasts the floor colour. It doesn't have to be tape, all that matters is there is a clear change in colour for the rover to detect. An alternative solution is to use a piece of coloured paper.
Your solutions should work no matter how far from the tape the rover starts. Make sure to test the same code from multiple starting positions.
### Heres Our Approach
#### **Stage 1**
First we need the rover to drive forward towards a change in colour. We tell the rover to move forward with a start moving motor block.
#### **Stage 2**
As the rover drives forward, we need to be constantly checking the colour sensor. Use a repeat until loop block where the condition is set to detect the desired colour. Our code is looking for the brightness of the white tape.
#### **Stage 3**
The rover will keep checking the colour sensor in the loop block until the condition is true. After the repeat we stop all motors.
#### Note
If the simple colour sensor blocks arent working we may need to use a different comparison block to check more detailed readings from the sensor. Use the rover sensor view to identify the one that will work best for you.
![](/images/content/98a2c4-screenshot-2023-05-24-123918.png)
Example Code 1
![](/images/content/e3ba7c-screenshot-2023-05-24-123918.png)
Example Code 2