Time

Lesson 1 - Year 5

Learning Intention

  • I can program a robot to say the date and time

Introduction

Ohbot saying the current date and time

What do you know about Ohbot? What code have you written for Ohbot in Year 3 and Year 4? This week we are going to be looking at how to make Ohbot speak and use some operators that report the date and time using a variable called 'current' that's built in to the Ohbot program. Look at your computer. What current information can you see displayed? In the bottom right is the current time. We can write some code to make Ohbot say the current time and date. The sound will work best through the headphones.

Teacher Input

Code using the say until done instruction with the current variable

Can you experiment with instructions from the Speech palette to make Ohbot talk? Write a program in which Ohbot talks. We will now work together to make Ohbot say the year. We need to start with the `say until done` instruction, then we need to go to the Sensing palette and scroll down to find the `current` variable. The `current` variable has a drop down menu and we need to select 'year'.

Ohbot will now say the year. However, if we go to the Operators palette and drag a `join` operator we can add our own text before the year. We can now use this program as a skeleton to say other current pieces of information. Children to now work through tasks on slides.

Activities

1.

Can you write some code to say the time, which includes the hour, minute and second?

Code saying the current hour, minute and second

Extension

Can you write some code to say the day name, date, month name and year?

Code saying the full current date

Plenary

Look at examples of the children's coding. Were they successful? Did they need to debug their code? Is everyone's code the same?

Ohbot image

Key Points

  • The `current` variable (Sensing palette) reports the date and time.
  • Its drop down menu selects year, month, date, day of week, hour, minute or second.
  • `say until done` makes Ohbot finish speaking before the next instruction runs.
  • The `join` operator (Operators palette) combines your own text with a variable's value.
  • One working program can be used as a skeleton for related tasks.

Need Help?

If you're stuck on any part of this lesson, check out these resources:

Ohbot