Year 6 - Lesson 3
(I'm Sleepy)
Learning Intention
- I can write a program that uses a variable to make Ohbot appear sleepy
Introduction
This week we are going to build on the skills we learnt in Year 4, using variables. We will Make a Variable and use this to control how sleepy or wide awake Ohbot acts.
This week we are going to build on the skills we learnt in Year 4, using variables. We will Make a Variable and use this to control how sleepy or wide awake Ohbot acts.
Teacher Input
We will build up the project in steages. Each stage will build upon the code we have written in the previous stage.
Activity 1: In the first stage we need to Make a Variable called sleepy which will count up in ones starting from 0.
We will build up the project in steages. Each stage will build upon the code we have written in the previous stage.
Activity 1: In the first stage we need to Make a Variable called sleepy which will count up in ones starting from 0.
Activity 2: We will add an if-then-else condition instruction and sense when the value of sleepy is greater than 10. Whenever it is it will make Ohbot go to sleep. We can put what we want Ohbot to do when it sleeps into the then part of the conditional. Here we make it nod its head, close its eyelids and say ‘Snore Snore Snore’. Encourage children to choose code to show Ohbot sleeping.
Activity 3: We need to think about what happens to Ohbot when Ohbot is not asleep. We can put the code to make Ohbot awake in the Else part of the conditional. In this case we’ve made Ohbot open its eyes, nod its head up and say that it’s wide awake. Challenge children to think about how they can show Ohbot is awake and add their code to the Else condition.
Activity 4: What if we wanted to wake Ohbot up. Can you think of how you could use a keyboard event to wake Ohbot up. Children might want to play a sound to ‘wake’ Ohbot up. Perhaps children can program Ohbot to look surprised when it wakes up?
Extension
Plenary
Take a look at the children’s own projects. Were they successful?
- Can you write code to make Ohbot appear a bit tired when the sleepy variable has a value between 5 and 10?
Plenary
Take a look at the children’s own projects. Were they successful?