Files
micromelon-website/content/resources/random-bug-bot.mdx
Tim Hadwen ae3ae18585 Major site overhaul: resources hub, content migration, new blog posts, forms
- Redesign /resources as sectioned hub with category pages
- Migrate 645 Squarespace CDN images to local /images/content/
- Create 9 new news/blog posts with event photos
- Fix blog post slugs (rename gibberish filenames)
- Rename Design Blog to Design Blogs across site
- Remove education page, replace with Platform in nav
- Redesign rover repair request form with dynamic rover entries
- Add school search combobox to contact, store, and repair forms
- Extract shared KNOWN_SCHOOLS data
- Make /rover-expansion-3d-printing dynamically pull from MDX
- Add related resources sections to product pages
- Fix homepage broken /quote links to /store
- Store page: sample kit cards, inline quote builder, mailing list opt-in
2026-03-01 17:14:05 +10:00

84 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", "All"]
tags: ["Iteration", "Motors", "Maths", "Beginner", "Colour Sensors"]
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.
####
Relevant Coding Skills
Branching
-->
Iteration
Functions
Variables
-->
Algorithm Design
-->
Maths
####
Relevant Rover Concepts
Ultrasonic
-->
IR
-->
Colour
Gyroscope
Accelerometer
Motors
LEDs
-->
Buzzer
-->
Activity Demonstration
### 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