Files
micromelon-website/content/resources/driving-shapes-2.mdx
Tim Hadwen 99534e779a Consistent hero layouts, activity page redesign, new content, and YouTube embeds
- Product pages (Code Editor, Robot Simulator): text-left/image-right hero layout
- Related resources capped at 3 items on all product pages
- Making Music activities renamed to I, II, III
- New Maze I/II/III and Sumo I/II/III difficulty-graded activities
- YouTube demo videos restored on 12 activity pages from old site
- Activity pages: two-column hero with coding skills & rover concepts tags
- Blog/news pages: same two-column hero layout with date
- Resource type extended with codingSkills, roverConcepts, tags fields
- Removed raw "Relevant Coding Skills/Rover Concepts" text from activity MDX

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 23:56:05 +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: Driving Shapes 2"
date: "2021-06-03"
categories: ["Activities", "All"]
tags: ["Iteration", "Variables", "Motors", "Maths", "Intermediate"]
codingSkills: ["Iteration", "Variables", "Maths"]
roverConcepts: ["Motors"]
excerpt: "Learn branching, variables maths, and motors."
featuredImage: "/images/resources/driving-shapes-2.png"
---
Program the rover to request a number from the user and drive in a shape with that many sides. For more advanced maths make the rover draw the shape with uneven length sides.
### Activity Demonstration
<iframe width="560" height="315" src="https://www.youtube.com/embed/sX_Ver-vq6I" title="Driving Shapes 2 Activity Demonstration" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen></iframe>
### Setup
All you need is a flat, uniform surface to drive on. Different surfaces have different friction properties. This means the tracks will slip differently dependent on where the rover is driving. Some movement blocks such as turn by degrees are calibrated for an average friction. When driving on other surfaces you may need to turn more or less to get the desired angle.
### Heres Our Approach
#### Stage 1
First we need to ask for a number of sides. We can use the request input block. This block returns this a text string. We need to convert it to an integer so that it can be used as a number. Once we have converted it we store the number in a variable called sides.
**Stage 2**
Once we have a number of sides we can create the code to draw our shape. We will need a repeat for number loop block to repeat the movement blocks for each side. This loop needs to run as many times as we have sides, so we put our sides variable block in the number of times it will repeat.
#### **Stage 3**
In each iteration of the loop we need to draw a side with movement blocks. We need to move forward and then turn by degrees. We can calculate how many degrees we need to turn each time a simple math operation. Divide 360 by our number of sides using a math operation block.
![](/images/content/4b02d9-drivingshapes2-answer.png)
Example Code