Scratch Artificial Intelligence
Intermediate
60 mins
Teacher/Student led
210 points
What you need:
Chromebook/Laptop/PC or iPad/Tablet

Autonomous Car

This lesson guides students through the process of programming an autonomous car using Scratch. Students will learn about how autonomous cars work, create a Scratch project, add and manipulate a car sprite, draw a test track, and program the car to navigate the track autonomously. The lesson also includes instructions on how to control the car's speed and make it reverse when it goes off track.
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 - How an autonomous car works

    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.


    2 - Create a new Scratch project

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

    https://scratch.mit.edu


    3 - Add the car sprite

    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.


    4 - Shrink the car

    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.

    5 - Draw a test track

    We're going to use the backdrop editor to draw a racing track. To open the backdrop editor do the following:

    1. Click on the stage backdrop in the bottom right. A blue box should appear around it.
    2. Click on the backdrops tab in the top left. You should now see the backdrop editor.

    Next we're going to draw a race track. First we will draw a green box that covers the stage area and then we will draw a black track. Follow these steps:

    1. Select the Rectangle tool ().
    2. Choose a green colour from the Fill tool.
    3. Draw a large box that covers the stage area.
    4. Select the paint brush tool ().
    5. Choose a black colour from the Fill tool.
    6. Set the thickness of the paintbrush to be 90.
    7. Draw a simple track (keep it simple for now, you can make more complicated tracks later!).

    Use the undo button if you make any mistakes. Once you've drawn your track click on the 'Code' tab up the top right of your screen.



    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