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

Mindful marty


If you have you been trying to outlast Marty in the Marty workout or just need a moment of calm, you need this Mindful Marty activity! You will do some mindful breathing with Marty and then follow Marty through a series of robot yoga poses. Bliss!

This activity guides you through how to write all the code needed for a calming mindful breathing and robot yoga routine. Once programmed, Marty will be your instructor so that you can follow along either alone or sharing the relaxation with others!

what you will need

What will you learn about?

  • How to move individual body joints
  • How to use blocks
  • How to use parallel programming
  • How to find a moment of calm...

extra information for educators

This activity is linked to the contents of lesson packs Programming Concepts 1 and 2.

It also offers the opportunity for cross-circular health and wellbeing work.

changing Marty's arm Position

Before we get started coding, we need to adjust how high Marty's arms can go. You will need a screwdriver like the small screwdriver that you used to assemble Marty for this.

We need to unscrew the small screws that are holding Marty's arms in position.

Once the arms are removed, you will see how the gears that move the arms are lined up. At the moment, the grooves are lined up vertically.

Lift off the lower gear and replace it so that the grooves are horizontal or nearly horizontal.

Then screw Marty's arms back in place. Phew!

Now when Marty's arms are lifted as high they are go, they are nearly straight up! This corresponds to a position of -128 when we code the movement of Marty's arm.

And at the lowest position, Marty's arms are nearly by Marty's side. This corresponds to a position of 127 when we code the movement of Marty's arm.

Blue Sky and Floating Cats

We want to start by creating a relaxing scene. Our scene is going to have a lovely blue sky with a cat floating in it!

Create a new Scratch 3 project with the Marty the Robot extension added.

Getting Started with Scratch 3

On the right hand side of the Scratch screen, there is the Stage with Scratch cat currently loaded onto it. We want to change the background that Scratch cat is currently on by hovering on the blue circle with an image logo that can be found in the bottom right of the screen. Then find the option that says Choose a Backdrop.

Select the Blue Sky backdrop by clicking on it.

To make the Scratch cat look as if it is floating, we can change its Costume. At the top left hand side of the Scratch screen above the code blocks, select the tab named Costume.


Click on the blue circle with an image logo that can be found in the bottom left of the screen. Then find the option that says Choose a Costume. We chose the Cat Flying-a costume because it was the most, well, floaty option!

Then we increased the size of the sprite to 150% to make it appear bigger on screen.

Hint: You can chose whatever costume you like for the sprite but remember we are trying to be restful here!

We are going to make our cat more colourful by setting it to a different random colour each time we run our code. The range of possible colour shades go from 1 to 200. We need a pick random block from the Operators section of the coding blocks. Set it to choose a number between 1 and 10. We think our cat looks a bit like a balloon now... we hope that is a good thing and the cat doesn't mind!

Hint: If you would rather set your sprite to be a particular colour, why not experiment with values and find the one that you like best!

Before we start writing the code to make the sprite move up and down and count mindful breaths for us, we want to move it to its start position.

The screen is a 480 by 360 rectangle. The x position can be any value from -240 (sprite as far left as possible) to 240 (sprite as far right as possible) and the y position can be any value from -180 (sprite as far down as possible) to 180 (sprite as far up as possible).

Select a go to block from the Motion blocks coding drawer. Set the x position to 0 and the y position to -40.

The code so far should look like this:

Mindful Breathing

Just like the Workout with Marty, the easiest way to breathe and move mindfully with Marty is to use a series of the blocks in the Marty extension.

As some of the movements and poses we program Marty to perform are quite complex, we can make our code easier to read if we can store the new moves we make in these 'blocks'. Then when we want Marty to perform one of our custom movements, instead of writing out all the steps again we can simply insert the block into our sequence! In other programming languages, these blocks of code are often called functions.

Make a block can be found under the My Blocks section of our coding blocks. The pop-up below will appear. Type the name of your new block into the block name section. After you have done this, you'll find a new block with the name you just entered appears in the My Blocks section.You'll also see a define block appear in the coding area.

Using My Blocks, we can define two blocks called breathe in and breathe out. We want to add a think block from the Looks option in the code blocks drawer. Set it to think the numbers 1, 2, 3 and 4 for 1.5 seconds each.

Hint: You can change how long each number is displayed for but watch you as you will need to adjust the float times for the sprite if you change the times!

Put the breathe blocks inside a forever loop from the Control blocks.

Next we want two glide blocks from the Motion coding blocks. We want the cat to gently glide up and then back down so keep the x position at 0 and set the y position to go from 40 to -40. Just like with the breathing, we want these blocks inside a forever loop. The time of 6 seconds is the total time it takes to breathe in and breathe out that we set when we defined the breathe in and breathe out blocks.

When we write programs that run multiple blocks of code at the same time we say we are parallel programming. Parallel programming reduces the time programs take to run and allows them to be run using multiple computers - that makes it super useful.

We are going to use parallel programming several times when we make the blocks for Marty's mindful moments and movements! The blocks that we need for parallel programming can be found in the Events coding drawer.

Make a broadcast message called float. Then we need run two different actions to make the cat move and to show the 1-2-3-4 counting! To do this we need to run our coding blocks in parallel. The code so far should now look like this:

Just above where you found the broadcast block in the Events coding block drawer, you will see a when I receive message1 block. This block will run when we broadcast the message. You want to receive the float message.

All that is left to do is to have two of these events happening - once for the floating cat movements and once for the counting!


Marty's mindful movements are based on a series of robot yoga poses! Each pose is based on a real yoga pose that us human beings can do too.

Marty should move slowly into each pose, hold the pose so you will need a wait block and then move slowly back out of the pose! Your Marty can try as many of the poses that you want and it doesn't matter about the order however Mountain pose is a good one to start with.

We would like Marty to finish by standing up straight ready for any further adventures so add the stand straight block from the Marty the Robot blocks after the repeat loop at the end of the code.

Again, to make your own block of code, click on the My Blocks button in the Scratch menu. Then click on the make a block button. Make a block called Mountain.

Unlike the other poses, Marty is going to start by leaning side to side in order to settle mindfully into Mountain pose! To to this we need a lean right and lean left block from the Marty the Robot blocks and we will put them inside a repeat loop. Then Marty will be ready to start on Mountain pose.

Here is the complete code using more Marty the Robot blocks to move various parts and broadcast and receive blocks for movements to happen in parallel:

Upwards Salute

Next Marty will do a mindful upwards salute!

Make a block called Upwards Salute.

Here is the complete code for the Upwards Salute block. Again it uses Marty the Robot coding blocks to move Marty's arms and broadcast and receive blocks to make these actions happen in parallel.

Half Forward Bend

Time for Marty to nearly touch those robot toes....does a Marty have toes? Hmmmmmm....

Make a block called Half Forward Bend.

Here is the complete code for the Half Foward Bend block. Again it uses Marty the Robot coding blocks to move Marty's arms and hips and broadcast and receive blocks to make these actions happen in parallel.


When you see Marty strike this pose, you will understand why it is called Triangle. If you try it, keep your legs straight in a triangle position, don't try to bend your knees like Marty or ouch!

Make a block called Triangle.

Here is the complete code for the Triangle block. Again it uses Marty the Robot coding blocks to move Marty's arms and knees and broadcast and receive blocks to make these actions happen in parallel.

Warrior i

Next we have two similar moves that can flow well from one to the other! They have a great name - Warrior pose. If you try this, imagine yourself being a warrior and hold your position remembering that you are strong.

Make a block called Warrior 1.

Here is the complete code for the Warrior 1 block. Again it uses Marty the Robot coding blocks to move Marty's arms and hips and broadcast and receive blocks to make these actions happen in parallel. It is a bit more complicated because we are wanting to broadcast and receive four different messages here - two for hips and the others for arms.

Warrior iI

This is the second Warrior pose. Pay attention to how the feet are positioned!

Make a block called Warrior 2.

Here is the complete code for the Warrior 2 block. Again it uses Marty the Robot coding blocks to move Marty's arms and hips and broadcast and receive blocks to make actions happen in parallel. It is less complicated than Warrior 1!


Finally our favourite pose! We could stand like this all day... Don't worry if your tree sways gently when you try to balance.

Make sure that Marty is on a level surface for this one.

Make a block called Tree.

Here is the complete code for the Tree block. It just uses Marty the Robot coding blocks to make Marty lean to the side, lift up a foot then move Marty's arms.

Making the Routine

Chill out time! We are going to put the mindful breathing together with a series of mindful Marty yoga poses. Then it's time for you to be mindful along with Marty - follow the mindful breathing and copy Marty's moves. Time to grab any other members of your household who you think could do with a relaxation session too... kids, grown ups, cats, dogs, teddy bears...

This final step is made much quicker because we wrote our own custom blocks of code for each pose! Instead of having to write out all the instructions every time we want Marty to perform a pose, we just need to add one of our yoga blocks into the program! Remember that as always Marty needs to warm up with a 'Get Ready' block.

This is our complete code for a mindful routine. It starts with mindful breathing for 60 seconds then goes through a series of yoga poses. It finishes by going back to Mountain pose for another 60 seconds of mindful breathing.

Hint: You can put the yoga blocks in any order and you can choose the repeat them too! You can also change how long the mindful breathing lasts for at the start and the end.


We don't want to become lop-sided and neither does Marty! Your challenge is to write extra code for some of the routines so that Marty does the reverse of some moves. For example, instead of standing on the right foot and lifting the left foot in Tree pose, Marty needs to stand on the left foot and lift the right foot instead!

Add some extra blocks into our routine so that Marty does the opposite in a move. Here are a few things you will need to think about,

  • Can you work out which moves are not symmetrical?
  • Can you work out how to do the opposite of a move? Try it out for yourself and note down what you need to do with your arms and legs or find a willing volunteer to help you!
  • You could add extra blocks to existing functions or make new functions for right and left moves!


Let's use Tree pose as an example. Here is the original Tree block:

It starts by leaning to the right so we want to lean to the left. Then instead of lifting the left foot, we want to lift the right foot. Finally, move the arms up into the air one by one. In this version, it is Marty's right arm followed by the left arm so we want to lift the left arm followed by the right arm in our reversed version.

So the code we are going to add to our Tree block looks like this:

What Next?

You have now just created your own Marty's mindful breathing and yoga pose blocks, put them together to make a routine and, in doing so, learned about how to programme your Marty by moving individual parts and using parallel programming. If you want to continue to explore this, here are a few ideas!

  • Try adding sounds to your mindful Marty moves. You could play different sounds in time with Marty moving the arms up and down!
  • Got more than one Marty? Try to make all the robots do a routine together!
  • Create your own mindful moves for Marty! Experiment with moving individual joints in different ways.