Scratch
Advanced
60 mins
Teacher/Student led
235 points
What you need:
Chromebook/Laptop/PC or iPad/Tablet

Make a Clock

Embark on an exciting journey to create your own digital clock using Scratch. You'll start by creating a new project, uploading a clock face, and drawing the hands of the clock. Then, you'll program each hand to move accurately, representing seconds, minutes, and hours. Finally, challenge yourself by turning your clock into an alarm clock.
Learning Goals Learning Outcomes Teacher Notes Lesson Files

Live Class Feed

This is a live feed of the latest activity by your students on this lesson. It will update in real-time as they work on the lesson.
Load previous activity

    1 - Create a new Scratch project

    Go to the Scratch website, create a new project and delete the cat sprite.

    2 - Upload the clock face

    Included with this step is a picture of a clock face. Save this picture to your computer and then upload it as a new sprite in your Scratch project.

    Add the following code to the clock sprite to make it appear exactly in the center of the stage area.

    when green flag clicked go to x (0) y (0)


    3 - Draw the seconds hand

    Now let's create the seconds hand of the clock by painting a new sprite.

    Use the line tool to draw a blue line that is 4 pixels thick. Start the line from the center where the little gray circle and cross is. Hold down the 'Shift' key while you are drawing it to draw a straight line.

    It is very important that you start it from the center, otherwise it will not line up correctly on the clock.

    Once you have drawn the seconds hand, add the following code to it so that it appears correctly on the clock face.

    when green flag clicked go to x (0) y (0)

    Click the green flag and check that it appears correctly on the clock face. If it is too long or too small you may need to edit it so that it is the right size.




    4 - Program the seconds hand

    As you know the seconds hand of a clock counts the 60 seconds of each minute by rotating in one full circle.

    If there are 360 degrees in one full rotation, the seconds hand will need to move 6 degrees each second as 6 X 60 = 360.

    In the sensing toolbox there is a current [second] block, this block works like a variable and it is automatically set to the amount of seconds of the current time. By multiplying the current second by 6, we will get what degrees to point the seconds hand to.

    Add the following code to the seconds hand sprite underneath the go to x: 0 y: 0 block.

    when green flag clicked go to x (0) y (0) // add the new code under here forever point in direction ((current [second v]) * (6)) end

    Once you have added the code, click on the green flag and the seconds hand should start rotating and point to each second.



    5 - Draw the minutes hand

    Now let's create the minutes hand of the clock by painting a new sprite.

    Use the line tool to draw a red line that is 8 pixels thick. Start the line from the center where the little gray circle and cross is. Hold down the 'Shift' key while you are drawing it to draw a straight line. The minutes hand should be shorter than the seconds hand.

    Again it is very important that you start it from the center, otherwise it will not line up correctly on the clock.

    Once you have drawn the minutes hand, add the following code to it so that it appears correctly on the clock face.

    when green flag clicked go to x (0) y (0)

    Click the green flag and check that it appears correctly on the clock face. If it is too long or too small you may need to edit it so that it is the right size.



    Unlock the Full Learning Experience

    Get ready to embark on an incredible learning journey! Get access to this lesson and hundreds more in our Digital Skills Curriculum.

    Copyright Notice
    This lesson is copyright of Coding Ireland. Unauthorised use, copying or distribution is not allowed.

    Scratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab. It is available for free at https://scratch.mit.edu
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more