Controlling cars with code

Part of:

Code Smart

Encounter Edu offers a classroom bundle for Code Smart Ages 11-14 which contains everything you need to get started with coding and robotics in your classroom.

Visit the store

Lesson overview

In the second lesson of this unit of work, we will introduce your class to the concept of using code to control cars. Your students will discuss how programming a car compares to programming a standard computer. Next, your class will work in groups to complete the main challenge of the second lesson: programming the robot to drive in different shapes around the classroom.

Learning outcomes

  • Understand the difference between hardware and software and how they relate to each other
  • Describe functions carried out by software and hardware
  • Get the robot moving with code
  • Learn about loops (repetition)
  • Debug programs
  • Identify and share problems encountered with solutions

Lesson steps

  1. Video opener (5 mins)
    Introduction to code and its relationship to hardware. This video will set this lesson’s challenge: to control your robot car with code.
  2. Classroom discussion (10 mins)
    Students will discuss the video and think about the hardware and software needed to control a real world autonomous vehicle.
  3. Make (25 mins)
    Introduction to the most common types of motor. Use the mBlock coding environment for the first time. Learn how to control the DC motors to get the robot moving in simple shapes.
  4. Test (10 mins)
    Test the robot moves as expected.
  5. Reflect (10 mins)
    Students will reflect on their learning, including problems they had and how they solved them. The class will discuss how the robot car would behave differently on different surfaces and how they would compensate for this.

Equipment required (per group)

  • mBot created in previous lesson
  • Laptop or tablet with mBlock software installed (see How to set up mBlock Subject Update)