Virtual Timer using Scratch

Create a Virtual Timer using Phiro robot and Scratch code! Make Phiro rotate for a given time and stop when time runs out.

Objective

By the end of this lesson, learners will

  • Understand how virtual timers work
  • Understand and use the computational concept of Variables and Conditionals
  • Create a fun timer program with a robot
  • Express their creativity by making a robotic timer
Subjects

Robotics, Coding, Maths.

Age

9 - 18 Years

Duration

45 min

Robot & Accessories Needed

Phiro Pro robot

Software

Scratch4Phiro

  • step1
  • step2
  • step3
  • step4
  • step5
  • step6
STEP 1

Ask

Think about how timer on a watch works?

How is that different from a virtual timer, like on a cell-phone or computer?

How do clocks match system time to given time?

How does the timer alert you when time runs out?

What all do you need to make your Phiro virtual timer work?

STEP 2

Imagine

Brainstorm what you will need in Scratch and Phiro to make your virtual timer. Breakdown the challenge into 3 parts.

  • Get minute & second time from user
  • Convert user given time to seconds
  • Check condition to make Phiro stop when given time runs out
STEP 3

Plan

Plan your Phiro virtual timer.

Explore condition blocks in Scratch and identify which one you will need to create a virtual timer. As the default timer block in Scratch uses only seconds, plan how you will convert the given minutes for timer in real time programming.

Plan your virtual timer in 3 parts:

  • Get minute & second time from user by creative a Variable. Explore the Sensing block in Scratch to get user time. Explore the Data block in Scratch to make Variables. Think about the variables you will need to get minutes, seconds, and total seconds in timer values from user.
  • Convert user given time to seconds. Explore the Operator block in Scratch and think about how to convert given time to seconds.
  • Check condition to make Phiro stop when given time runs out. Explore Phiro's move blocks.
STEP 4

Create

Create your Phiro Virtual Timer in 3 parts:

1. Get minute & second time from user Make 3 Variables: Minute, Seconds, Total Seconds

Get timer value of Minute from user using Ask brick.

Get timer value of Seconds from user using Ask brick.

2. Convert user given time to seconds Calculate total no of seconds using formula.

3. Check condition to make Phiro stop when given time runs out

Repeat code until default timer > total seconds in Timer variable.

Turn Right until above condition becomes true.

Stop Phiro. Stop all Scripts.

Virtual Timer - Script


Test your code and watch if Phiro has followed your instructions. Did it do as expected? What did you do to improve your alarm?

STEP 5

Remix

  • Remix the virtual timer code to include Hour time or try making Phiro do fun different stuff while waiting for the time to run out!
STEP 6

Share

Share your virtual timer Phiro creation using #MyPhiro @RobotixLS and we will share it with the world!