How to use the
Learning Portal

Learning Portal

Our hands-on, comprehensive lesson plans span a range of levels. Browse our free STEM and coding learning resources.

Marty Image

Teach Marty V2 to Walk


Using Scratch 3, you will code Marty walking without using the built in command. You will need to think about how different parts of Marty's body need to move to step right and left. You will progress from writing simple code to control Marty to more sophisticated code that uses functions and variables!

Marty can be coded to walk without using the built in command.

Starting with code for just single steps to the right and left, the way that Marty's body parts need to move are then controlled using functions and variables.

What you will need

  • A device with our Marty the Robot v2 app downloaded and up to date
  • Marty the Robot v2

What will you learn about?

  • Experimentation
  • Sequencing
  • Loops
  • Variables

Extra information for educators

This activity may sound simple but is packed full of indispensible concepts that form the foundation of much programming! Student will see that code can be written in different ways but achieve the same result.

every journey starts with a single step!

We are going to start by keeping it simple and just take it one step at a time...literally.

Open up the Marty the Robot v2 app and follow the instructions there to connect your robot to the app. Then click on Code with Scratch to open a new Scratch project ready for coding,

There are already built-in blocks that will program Marty to take steps forwards and backwards but how about we teach Marty how to walk ourselves without these blocks! We need to think about breaking down a complex movement like walking into smaller, individual movements whilst thinking about balance and the individual joints.

First, let’s think about how we would walk. This is quite a difficult movement to break down because we’re so used to doing these movements without too much thought or fuss!

We lift one leg, move it forward a bit and then put it back down on the ground. Then the other leg does the same. But there’s something else happening in the background. What happens to our weight when we’re standing on one leg? It shifts to the side that is still connected to the ground!

If we try putting all of that together, we get the following blocks to take one step with our right leg,

But we usually need to take steps with one leg after the other like so,

Next Step: Using Functions

Let’s say we wanted to take more than two steps, that would take a lot of repeated blocks of code, so we’ve introduced some functions here.

Go to My Blocks and click on Make a Block.

Make functions called step left and step right to represent taking a step with our left leg and taking a step with our right leg. Now we can just call these functions using these blocks when we want to take a step with that leg. We have joined the code blocks that we put together previously for each step to the define blocks. 

Then all that is left to do is to tell Marty to repeat stepping forward with each foot. We can do that using a repeat block that can be found in the Control section,

What Next?

You have now just programmed Marty in different ways to walk without the built in walk function using Scratch. If you want to continue to explore how Marty can move without using the built in functions, here is how to get going!

  • Pick a different built in function and try to break it down into individual joint movements. Act it out yourself to help!
  • Try to write code to make Marty move in the same way but without the built in function.
  • When you have got Marty moving correctly, think about ways you could write your code differently. Remember how we used functions and variables!