Files
micromelon-website/content/resources/random-bug-bot.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

40 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: Random Bug Bot"
date: "2021-06-03"
categories: ["Activities"]
tags: ["Iteration", "Motors", "Maths", "Beginner", "Colour Sensors"]
codingSkills: ["Iteration", "Maths"]
roverConcepts: ["Motors", "Colour"]
excerpt: "Learn branching using the motors and maths."
featuredImage: "/images/resources/random-bug-bot.png"
---
Program the rover to act like a bug and move around randomly looking for food. Using the random number math block generate a speed for each of the motors. This will create a randomly moving bug rover.
### Activity Demonstration
<iframe width="560" height="315" src="https://www.youtube.com/embed/xiA_f1Zi-b8" title="Random Bug Bot Activity Demonstration" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen></iframe>
### Setup
The random number generation of the rovers speed in our approach will have the rover move around randomly. Depending on the ranges students use, their random numbers may result in rovers driving a long way. Make sure to set the speeds and durations to suit the space you have and keep an eye on the rovers while theyre driving.
### Heres Our Approach
#### **Stage 1**
Start with an advanced motor block for setting different speeds for our left and right motors. Inside each of these slots we can use the random integer block from our math category. We use the numbers -15 to 15, any number that is negative will cause the motor to go backwards. The block has a chance of setting either motors to go forward or backward.
#### **Stage 2**
We need to control how long our rovers run at this speed. We can use the delay block to tell our code to continue what its doing for now. To continue the trend of our rover being unpredictable we will use another random integer block to set a random number between 1 and 3 for the amount of seconds our rover will move.
#### **Stage 3**
After the delay has ended we want our rover to pick new random speeds so we place the code in a repeat while true loop.
![](/images/content/baeebc-randombugbot-answer.png)
Example Code