Teach Marty How t0 Walk

Learn to break down commands by teaching Marty how to walk! 


what you will need

  • Marty the Robot
  • Laptop/Computer/Tablet
  • Access to either Scratch or Python editors


  • 45 Minutes  

What will you learn about?

  • Experimentation 
  • Sequencing 
  • Loops
  • Variables
  • Functions

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 left leg,

first steps

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

first steps

Let’s say we wanted to take more than two steps, that would take a lot of repeated blocks of code, so I’ve introduced some functions here to represent taking a step with our left leg and taking a step with our right leg. Now we can just call these functions when we want to take a step with that leg.

first steps

Wouldn’t it be nice if we didn’t have to specify which leg we wanted to step with? After all, how often do you think about which left needs to take the next step when you’re walking? We can do that easily by introducing a variable to keep track of what leg we just used to take a step,

first steps

We now have a walking Marty!

If you want to take it one step further, you could explore moving the individual different joints such as the hip, twist or knee with the following block!

first steps