Movement, Looks, Control
Programming with Scratch Jr - Lesson 1
Objectives
- To create and debug simple programs
- To program the movement and appearance of an on-screen sprite
- To use logical reasoning to predict the behaviour of simple programs
Lesson Resources
- Lesson slides
- (if using tablets) A way to display your tablet on your classroom screen (Reflector 2, AirServer, Dongle)
Lesson 1 - Movement, Looks, Control
Lesson 2 - Multi-sprite animations
Lesson 3 - Triggering actions
Lesson 4 - Programming stories
Lesson 5 & 6 - Programming games
Introduction
If you need help yourself getting started with ScratchJr before your lessons, there are some useful resources built into the app. From the home menu go to the question mark at the top of the screen for a quick intro video and some sample projects.
Go to the book icon to find more information about ScratchJr, a guide to the interface, a guide to the paint editor and a guide to all the blocks available.
Begin by setting the scene for the unit and establishing the understanding and experience of your students with regard to coding or programming. Ask: What is programming? What does it mean if I program something? Programming is typically giving instructions to machines to make them do something. This could be many different things working in lots of different ways. For example, we can program our TV box to record a program we like or our alarm clock to wake us up at a certain time. We tell the machine what to do in both of these examples by pressing buttons (on the device or a remote control), but we’re not actually writing the code for the machines to do it, we’re just using the menus and options that someone has already set up for us (with code).
Ask: What is an algorithm? An algorithm is a sequence of instructions to make something happen or solve a problem. Algorithms can also be written in lots of different ways. It could be a recipe to bake a cake, instructions to build a model or code to make a computer game work.
A computer programmer attempts to take problems, think of solutions and then writes algorithms with computer code to make a computer do something either onscreen or to control something happening in the real world, such as traffic lights or an automatic door.
Programmers don’t always get things right first time, sometimes they make mistakes and put bugs in their code. Ask: What do you think debugging is? This is just a word to describe the process of looking for and fixing mistakes in your algorithm, something that we do at school all the time with our other work.
Our tablets are a kind of computer, and we are going to learn a computer programming language called ScratchJr to control them. We’ll be learning the language by experimenting and trying things out on our tablets.
Connect your tablet to your display screen and introduce the app. Tap the Home button and then start a new project by tapping the + sign.
Explain that this is the main screen in the app when you are working on a project. The large box in the middle is where we see our project working. To begin with, Scratch the cat is the sprite that we are controlling. You can drag him anywhere on the screen to choose where he begins. Our programming language is made up of blocks that we can join together like jigsaw pieces, these will make up our algorithms. Each block does something different and we are going to start by exploring just the blue blocks.
Movement
Select the right arrow block and demonstrate how to drag a block from the palette to the programming area, it doesn’t matter where it goes as long as it’s in this area. Remember, each block gives an instruction to our sprite, Ask: what do you think this block will tell Scratch to do? Let’s see! Run the block by tapping on it in the programming area. Ask: Were we right? How could I make him move further to the right? Some children may suggest adding more of the same block, which will work, Ask: but what problem could we have if we want him to move a long way? We would need lots of blocks which would be time-consuming to build and take up a lot of space in our programming area. Demonstrate a better way. The block is actually giving Scratch two instructions, which way to move and how far to move, the number 1 below the arrow tells Scratch how far to go. If we tap on this we can change it to a bigger number using the keypad that appears.
So one block with a 3 will do the same thing as these three blocks with a 1, Ask: which is better?
Ask: What do you think the next three blocks will do? Establish and demonstrate that these also control direction and we can change their distance as well.
The students' first task is to explore these themselves and also work out what the rest of the blue blocks do. Encourage the students to try each block on its own first, change numbers if there is one and see what happens.
After a few minutes of them working, show how the pieces can be clicked together to create an algorithm with a series of instructions. Ask: What happens now when I tap the blocks? It always starts with the first block on the left and runs through the program to the right, in order. Ask: Will it ever run backward? What happens if I break the blocks in half? Why have some stopped working? They can try this too.
After a few more minutes, stop the class, and ask students to explain and demonstrate what each of the last four blocks do.
These rotate your sprite clockwise and anti-clockwise, jump, and return the sprite to wherever they started (and re-orientates them too). Ask: Why doesn’t the last block do anything on its own? It can only return you to the start if you’ve moved!
We can describe all of these blue blocks as movement blocks.
Ask: How could use our blue movement blocks to make Scratch the cat move in a perfect square? What do you know about squares that could help us? Establish that squares have four equal sides and then let them have a go. After a few minutes ask someone to demonstrate how they did it. Ask: is there only one way to solve this problem? No, we didn’t specify where to start the square or how big it should be so there are lots of different possible ways to make a square, e.g.
Ask: How could you change your algorithm to make Scratch move in a rectangle instead? What do you know about rectangles that can help you? Establish that rectangles also have four sides but that they are not all equal in length, and then let them have a go. After a few minutes ask someone to demonstrate how they did it. Ask: is there only one way to solve this problem? No, we didn’t specify where to start the rectangle, how big it should be or whether it should be short and wide or tall and thin, so there are lots of different possible ways to make a rectangle, e.g.
Ask: Can you keep your rectangle the same size, but reverse the direction in which Scratch moves around your rectangle? i.e. change clockwise to anti-clockwise or vice versa. So the above algorithms would become:
Looks
Clear away any blue blocks from your screen by dragging them back to the palette. Next tap the purple category icon to switch to the ‘looks’ blocks
Drag out just the first speech bubble block and demonstrate how this works. Tap the word ‘hi’ below the block and the keyboard will appear on your tablet letting you edit the speech bubble, change ‘hi’ to ‘good afternoon everyone’ (or something of your choice) and then tap to the side or on the ‘go’ button to get rid of the keyboard. Then show how tapping the actual block will make Scratch say whatever you have just typed in.
Explain that their next job is to try this out and also explore the rest of the purple blocks and be ready to report back on what they all do in a few minutes.
Ask different children to explain what they found and demonstrate on the front screen as they explain. These blocks change the size of the sprite and also hide and show it.
Ask: Can you now combine the purple blocks with some blue movement blocks to make a longer, cooler algorithm?!
Give them plenty of time to experiment with these blocks together, some children could show what they have done if you have the facility to connect their tablet to your screen.
Control
Finally today, we are going to check out the orange blocks.
These are control blocks and don’t do very much on their own, for that reason, tell the students that they will need to use them with some blue blocks.
Give them a few minutes to explore. Ask: Can you work out what each orange block does?
Go through each of the orange blocks and see if they can explain what they do and how they work, some are trickier than the blue and purple blocks to work out!
Wait
This is a wait block and makes the sprite stop for a specified amount of time.
10 on the block = 1 second
20 on the block = 2 seconds etc
Ask: What number would I need for four seconds? How long would it wait if I put 100 in the wait block?
Stop
This block stops the sprite. It can be used at the end of an algorithm, or in more often in game-type projects or animations with the bump block (if you bump another sprite, stop)
Speed
This sets the speed of the sprite’s movement and therefore you need to use it with movement blocks or you don’t see the speed change. You can place it at the beginning to set the speed for a whole program:
Or you can have more than one speed block to change the speed at some point in your program, e.g. fast then slow:
Repeat
This is a counted loop which repeats code. What does repeat mean? You wrap this block around other blocks. Drag it close to others and you’ll see a grey shadow appear showing you where it will go when you release your finger. To remove it, take the blocks out from inside it.
You can repeat all your code e.g.
Or just part of your code:
The number below the repeat block is how many times it will repeat the actions inside it.
Plenary
To assess their understanding of what’s been covered in this lesson, ask them to work with a partner and take a look at the following algorithms, can you explain what each one would do to the sprite on the screen?
(Move right 5 steps, jump, Move right 5 steps, jump, go back to the start.)
(Move in a square with sides of 6 steps, then do a full clockwise spin)
(Say ‘hi’, move right 5 steps, up 6 steps, get bigger, move down 7 steps, do a full clockwise spin, get smaller, move left, return to normal size)
(Set speed to slow, jump, do a full clockwise spin, move right 3, do a full anti-clockwise spin, say ‘Bye!’, hide, wait for 3 seconds, show and say ‘hi’)
(Set the speed to fast, move right 15 steps, set the speed to medium, move left 10 steps, get bigger, repeat a square with sides of 4 steps 4 times, say ‘Bye!’, hide)