Scratch
Beginner
40 mins
Teacher/Student led
+170 XP

Studio: Autonomous Car

Students build a self-driving car in Scratch that uses colour sensors and conditionals to stay on a track, then discuss how sensing and decisions create smart-looking behaviour.

Teacher Class Feed

Load previous activity

    1 - Start: What We're Building ~4 mins

    Illustration for Start: what we're buildingToday you are coding in Scratch. You will build an autonomous car that senses the track and steers by itself.

    You can already make sprites move and respond to events. Today you will use sensing and decisions so the car follows a track without you steering every turn.

    Before you run anything, think: what might the car need to notice so it can stay on the road?

    2 - How an Autonomous Car Works ~2 mins

    What is an autonomous car?
    An autonomous car (also known as a driverless car, self-driving car or  robotic car) is a car that is capable of sensing what is around it and navigating without a person driving.

    How does it work?
    Autonomous cars use a variety of techniques to detect their surroundings, such as radar, laser light, GPS, odometry and computer vision. They have advanced control systems that interpret sensory information to identify appropriate navigation paths, as well as obstacles and relevant signage.

    The following 2 minute video shows some of the different cameras that a Tesla autonomous car uses to sense where the road is and all the different objects that it comes close to such as people and other cars.


    3 - Create a New Scratch Project ~2 mins

    Let's program our own autonomous car! First, create a new Scratch project and delete the cat sprite.

    https://scratch.mit.edu


    4 - Add the Car Sprite ~2 mins

    Included with this step is a car picture that we're going to upload into our Scratch project. First download the picture file onto your computer and then upload it into your project.

    You may notice the red, blue and orange ellipses sticking out of the front of the car. We will be using these as the car's sensors to navigate around the track.


    5 - Shrink the Car ~2 mins

    As the car sprite is very large, we'll need to shrink it so that it has room to move around. We're going to shrink it to 10% of it's original size.

    Add the following code to the car sprite:

    when green flag clicked set size to (10) %

    Click on the green flag and the car should shrink to 10% of it's original size.

    123learn · Online learning platform

    Unlock the full learning experience

    You're previewing this lesson. Get full access to this lesson and hundreds more — each one ready to teach, with interactive activities, printable resources and pupil progress tracking built in.

    Hundreds of curriculum-aligned lessons
    Interactive activities in every lesson
    Printable resources & progress tracking
    Copyright Notice
    This lesson is copyright of Coding Ireland 2017 - 2025. 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