MINDSTORMS EV3 Core Set

Make a Speed Control System

Design a cruise control system that changes the speed of a vehicle when a button is pressed.

120+ min.
Intermed.
Years 10-13
set-cruise-controle

Lesson plan

Prepare
- Read through this teacher material.
- If you feel that it is necessary, plan a lesson using the getting started material in the EV3 Lab Software or Programming App. This will help to familiarise your pupils with LEGO® MINDSTORMS® Education EV3.

Engage (30 Min.)
- Use the ideas in the Ignite a Discussion section below to engage your pupils in a discussion relating to this project.
- Explain the project.
- Divide your class into teams of two pupils.
- Allow your pupils some time to brainstorm.

Explore (30 Min.)
- Have your pupils create multiple prototypes.
- Encourage them to explore both building and programming.
- Have each pair of pupils build and test two solutions.

Explain (60 Min.)
- Ask your pupils to test their solutions and to choose the best one.
- Make sure that they can create their own testing tables.
- Allow some time for each team to finalise their project and to collect assets for documenting their work.

Elaborate (60 Min.)
- Allow your pupils some time to produce their final reports.
- Facilitate a sharing session in which each team presents their results.

Evaluate
- Provide feedback on each pupil's performance.
- In order to simplify the process, you can use the assessment rubrics that have been provided.

Ignite a Discussion

The cruise control function on cars is a system that automatically controls the vehicle's speed. Even though it seems like a modern technology, it was first introduced in 1958. So how does it work?

set-cruise-controle

Encourage an active brainstorming process.

Ask your pupils to think about these questions.

  • What is the purpose of cruise control in a car?
  • How does cruise control assist the driver during long journeys?
  • How might cruise control be improved?
  • How would a driver use a touch button speed control system?
  • What elements must be included in your program in order to turn button presses into motor speed changes?

Give your pupils some time to answer these questions.

Encourage your pupils to document their initial ideas and to explain why they chose the solution that they will use for their first prototype. Ask them to describe how they will evaluate their ideas throughout the project. That way, when they are reviewing and revising, they will have specific information that they can use to evaluate their solution and decide whether or not it was effective.

Building Tips

Start by building a vehicle. Your pupils may use any of the suggested LEGO® MINDSTORMS EV3 Driving Base models or design their own model. Make sure that they include buttons that simulate the buttons that are found on the steering wheel of a car with cruise control.

ev3-robot-color-sensor

Using two Touch Sensors

Explain that in today’s lesson, your pupils will utilise two Touch Sensors to control and maintain the speed of their Driving Base model.

Coding Tips

Your pupils will most likely use a Variable Block in this project. A Variable Block is a programming block that can store data (i.e. text, logic, a numeric or arrays), which can be overwritten at any time while the program is running.

A variable is a way of storing values that can change while a program is being executed. The value that is stored in a variable can be overwritten time and time again as long as the program is running.

Increase Speed with Variable Program

coding-07-01

Explanation of the Program

  1. Start the program.

  2. Create a Variable Block called ‘Speed’ and enter a value of 0.

  3. If the Touch Sensor is pressed:

    a. Read the variable called ‘Speed’.
    b. Add ‘10’ to the read value.
    c. Write the result in the variable called ‘Speed’.
    d. Read the variable called ‘Speed’.
    e. Start motors B and C at a speed set to the value that is stored in the variable called ‘Speed’ ELSE (do nothing).

  4. Repeat steps 3a to 3e forever.

Increase and Decrease Speed with Variable

coding-07-02

Explanation of the Program

  1. Start the program.
  2. Create a Variable Block called ‘Speed’, enter a value of 0 and start two tasks.

TASK 1
3. If Touch Sensor 1 is pressed:

a. Read the variable called ‘Speed’.
b. Add ‘10’ to the read value.
c. Write the result in the variable called ‘Speed’.
d. Read the variable called ‘Speed’.
e. Start motors B and C at a speed set to the value that is stored in the variable called ‘Speed’ ELSE (do nothing).

  1. Repeat steps 3a to 3e forever.

TASK 2
5. If Touch Sensor 2 is pressed:

a. Read the variable called ‘Speed’.
b. Subtract ‘10’ from the read value.
c. Write the result in the variable called ‘Speed’.
d. Read the variable called ‘Speed’.
e. Start motors B and C at a speed set to the value that is stored in the variable called ‘Speed’ ELSE (do nothing).

  1. Repeat steps 5a to 5e forever.

Increase and Decrease Speed with Variable and Display
Have your pupils use the Display Block to display the speed of the Driving Base.

coding-07-03

Explanation of the Program

  1. Start the program.
  2. Create a Variable Block called ‘Speed’, enter a value of 0 and start three tasks.

Task 1
3. Start My Block ‘Acceleration’.

Task 2
4. Start My Block ‘Deceleration’.

Task 3
5. Read the variable called ‘Speed’.
6. Display the value that is stored in the variable called ’Speed’.
7. Repeat steps 5 and 6 forever.

DOWNLOAD SAMPLE PROGRAMS15 KB, Requires EV3 Lab Software

EV3 MicroPython Program Solutions

Increase Speed with Variable

#!/usr/bin/env pybricks-micropython

from pybricks import ev3brick as brick
from pybricks.ev3devices import Motor, TouchSensor
from pybricks.parameters import Port, Stop, Button
from pybricks.tools import wait
from pybricks.robotics import DriveBase

# Configure 2 motors with default settings on Ports B and C.  These
# will be the left and right motors of the Driving Base.
left_motor = Motor(Port.B)
right_motor = Motor(Port.C)

# The wheel diameter of the Robot Educator Driving Base is 56 mm.
wheel_diameter = 56

# The axle track is the distance between the centers of each of the
# wheels.  This is 118 mm for the Robot Educator Driving Base.
axle_track = 118

# The Driving Base is comprised of 2 motors.  There is a wheel on each
# motor.  The wheel diameter and axle track values are used to make the
# motors move at the correct speed when you give a drive command.
robot = DriveBase(left_motor, right_motor, wheel_diameter, axle_track)

# Set up the Touch Sensor on Port 1.  It is used to increase the speed
# of the robot.
increase_touch_sensor = TouchSensor(Port.S1)

# Initialize the "old_speed" variable to "None."  It is used to check
# whether the speed variable has changed.  Setting it to "None" ensures
# this check will be "True" when the speed variable is initialized with
# a value.
old_speed = None

# Initialize the speed variable to 0.
speed = 0

# This is the main part of the program.  It is a loop that repeats
# endlessly.
while True:

    # Check whether the Touch Sensor is pressed, and increase the speed
    # variable by 10 mm per second if it is.
    if increase_touch_sensor.pressed():
        speed += 10
    
    # If the speed variable has changed, update the speed of the robot.
    if speed != old_speed:
        old_speed = speed
        robot.drive(speed, 0)

    # Wait 200 milliseconds before starting the loop again.
    wait(200)

Increase and Decrease Speed with Variable

#!/usr/bin/env pybricks-micropython

from pybricks import ev3brick as brick
from pybricks.ev3devices import Motor, TouchSensor
from pybricks.parameters import Port, Stop, Button
from pybricks.tools import wait
from pybricks.robotics import DriveBase

# Configure 2 motors with default settings on Ports B and C.  These
# will be the left and right motors of the Driving Base.
left_motor = Motor(Port.B)
right_motor = Motor(Port.C)

# The wheel diameter of the Robot Educator Driving Base is 56 mm.
wheel_diameter = 56

# The axle track is the distance between the centers of each of the
# wheels.  This is 118 mm for the Robot Educator Driving Base.
axle_track = 118

# The Driving Base is comprised of 2 motors.  There is a wheel on each
# motor.  The wheel diameter and axle track values are used to make the
# motors move at the correct speed when you give a drive command.
robot = DriveBase(left_motor, right_motor, wheel_diameter, axle_track)

# Set up the Touch Sensor on Port 1.  It is used to increase the speed
# of the robot.
increase_touch_sensor = TouchSensor(Port.S1)

# Set up the Touch Sensor on Port 2.  It is used to decrease the speed
# of the robot.
decrease_touch_sensor = TouchSensor(Port.S2)

# Initialize the "old_speed" variable to "None."  It is used to check
# whether the speed variable has changed.  Setting it to "None" ensures
# this check will be "True" when the speed variable is initialized with
# a value.
old_speed = None

# Initialize the speed variable to 0.
speed = 0

# This is the main part of the program.  It is a loop that repeats
# endlessly.
#
# First, increase the speed variable if Touch Sensor 1 is pressed.
# Second, decrease the speed variable if Touch Sensor 2 is pressed.
# Finally, the robot updates its speed if the speed variable was
# changed.
#
# Then the loop starts over after a brief pause.
while True:

    # Check whether Touch Sensor 1 is pressed, and increase the speed
    # variable by 10 mm per second if it is.
    if increase_touch_sensor.pressed():
        speed += 10
    
    # Check whether Touch Sensor 2 is pressed, and decrease the speed
    # variable by 10 mm per second if it is.
    if decrease_touch_sensor.pressed():
        speed -= 10
    
    # If the speed variable has changed, update the speed of the robot.
    if speed != old_speed:
        old_speed = speed
        robot.drive(speed, 0)

    # Wait 200 milliseconds before starting the loop again.
    wait(200)

Increase and Decrease Speed with Variable and Display

#!/usr/bin/env pybricks-micropython

from pybricks import ev3brick as brick
from pybricks.ev3devices import Motor, TouchSensor
from pybricks.parameters import Port, Stop, Button
from pybricks.tools import wait
from pybricks.robotics import DriveBase

# Configure 2 motors with default settings on Ports B and C.  These
# will be the left and right motors of the Driving Base.
left_motor = Motor(Port.B)
right_motor = Motor(Port.C)

# The wheel diameter of the Robot Educator Driving Base is 56 mm.
wheel_diameter = 56

# The axle track is the distance between the centers of each of the
# wheels.  This is 118 mm for the Robot Educator Driving Base.
axle_track = 118

# The Driving Base is comprised of 2 motors.  There is a wheel on each
# motor.  The wheel diameter and axle track values are used to make the
# motors move at the correct speed when you give a drive command.
robot = DriveBase(left_motor, right_motor, wheel_diameter, axle_track)

# Set up the Touch Sensor on Port 1.  It is used to increase the speed
# of the robot.
increase_touch_sensor = TouchSensor(Port.S1)

# Set up the Touch Sensor on Port 2.  It is used to decrease the speed
# of the robot.
decrease_touch_sensor = TouchSensor(Port.S2)

# Initialize the "old_speed" variable to "None."  It is used to check
# whether the speed variable has changed.  Setting it to "None" ensures
# this check will be "True" when the speed variable is initialized with
# a value.
old_speed = None

# Initialize the speed variable to 0.
speed = 0

# This is the main part of the program.  It is a loop that repeats
# endlessly.
#
# First, increase the speed variable if Touch Sensor 1 is pressed.
# Second, decrease the speed variable if Touch Sensor 2 is pressed.
# Finally, the robot updates its speed if the speed variable was
# changed, and displays it on the screen.
#
# Then the loop starts over after a brief pause.
while True:

    # Check whether Touch Sensor 1 is pressed, and increase the speed
    # variable by 10 mm per second if it is.
    if increase_touch_sensor.pressed():
        speed += 10
    
    # Check whether Touch Sensor 2 is pressed, and decrease the speed
    # variable by 10 mm per second if it is.
    if decrease_touch_sensor.pressed():
        speed -= 10
    
    # If the speed variable has changed, update the speed of the robot
    # and display the new speed in the center of the screen.
    if speed != old_speed:
        old_speed = speed
        robot.drive(speed, 0)
        brick.display.clear()
        brick.display.text(speed, (85, 70))

    # Wait 200 milliseconds before starting the loop again.
    wait(200)

Extensions

Language Arts Extension

Option 1
To incorporate the development of language arts, have your pupils:

  • Use their written work, sketches and/or photos to summarise their design process and create a final report
  • Create a video demonstrating their design process starting with their initial ideas and ending with their completed project
  • Create a presentation about their program
  • Create a presentation that connects their project with real-world applications of similar systems and describes new inventions that could be made based on what they have created.

Option 2
In this lesson, your pupils created a speed control interface. Individuals and agencies collect vehicle speed data to report traffic conditions and reduce the chances of traffic accidents.
To incorporate the development of language arts, have your pupils:

  • Write an argument to support the claim that by collecting motor vehicle speed data in order to monitor traffic safety, private individuals or agencies could effectively reduce the frequency of motor vehicle accidents
  • Use specific evidence to weigh the strengths and weaknesses of opposing arguments addressing the counter-claim that this practice is a significant violation of personal data privacy

Maths Extension

In this lesson, your pupils created a speed control interface. Human drivers are skilled at assessing road conditions and changing their speed accordingly. However, driverless systems must be trained to do this.
To incorporate the development of maths skills and explore the artificial intelligence behind driverless vehicles, have your pupils:

  • Contemplate the different variables they should examine to determine the relationship between road conditions and their effect on a vehicle’s handling and performance
  • Choose three or four of these variables to include in a mathematical model of road conditions and create a data table to organise the relationships between these variables and the vehicle's ideal speed
  • Keeping in mind that driverless vehicles use the machine learning process to identify and update the relationships between road condition variables and vehicle speed, identify road condition variables for dry, wet, and snowy roads and then predict the relationship between those variables and safe speeds (e.g. a dry road variable might be the roughness of the road)

Assessment Opportunities

Teacher Observation Checklist
Create a scale that suits your needs, for example:

  1. Partially accomplished
  2. Fully accomplished
  3. Overachieved

Use the following success criteria to evaluate your pupils' progress:

  • The pupils are able to identify the key elements of a problem.
  • The pupils are autonomous in developing a working and creative solution.
  • The pupils are able to communicate their ideas clearly.

Self-Assessment
Once your pupils have collected some performance data, allow them a bit of time to reflect on their solutions. Help them by asking questions, like:

  • Is your solution meeting the Design Brief criteria?
  • Can your robot’s movement(s) be more accurate?
  • What are some ways in which others have solved this problem?

Ask your pupils to brainstorm and document two ways in which they could improve their solutions.

Peer Feedback
Encourage a peer-review process in which each group is responsible for evaluating their own as well as others’ projects. This review process can help the pupils to develop skills in giving constructive feedback as well as sharpen their analytical skills and their ability to use objective data in order to support an argument.

The pupils who enjoyed this lesson might be interested in exploring these career pathways:

  • Business and Finance (Entrepreneurship)
  • Manufacturing and Engineering (Pre-Engineering)

Teacher Support

The pupils will:
- Use the design process to solve a real-world problem

**National curriculum in England **
Design and technology programmes of study: key stage 3 (DFE-00192-2013)

• identify and solve their own design problems and understand how to reformulate problems given to them

• test, evaluate and refine their ideas and products against a specification, taking into account the views of intended users and other interested groups

• develop and communicate design ideas using annotated sketches, detailed plans, 3-D and mathematical modelling, oral and digital presentations and computer-based tools

• understand how more advanced electrical and electronic systems can be powered and used in their products [for example, circuits with heat, light, sound and movement as inputs and outputs]

• apply computing and use electronics to embed intelligence in products that respond to inputs [for example, sensors], and control outputs [for example, actuators], using programmable components [for example, microcontrollers].

Pupil Material

Student Worksheet

Download to view and share the student worksheet.

Share with:

Google ClassroomGoogle Classroom