Controlling cars with code

Download Lesson Download

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)
activity age bookmark-fill icon bookmark boy-girl calendar chevron-down icon close icon compass cross icon download encounter-live facebook gallery icon instagram icon Instagram icon linkedin links icon location mail icon map next play previous professional-development right-arrow icon search share single image social-media speaker spinner icon students subject-update teacher-resources tick icon time twitter user video-lesson video youtube