CCW Cohort Teachers, click on the link below to access editable worksheets and presentation slides.

Lesson Overview


This is a programming lesson that models cell movement up a chemical gradient, model with the chemotaxis mat that has a white to black gradient printed on it. In this lesson, students build on the idea of outlining a program as a series of scenarios and responses. This program is a bit more complex than the phototaxis program lesson as they will need to build their chemotaxis program from scratch. They are given a program called Chemosense that helps them calibrate the color sensor to the chemotaxis mat. At the end of this activity, student groups are asked to present their completed chemotaxis program.

Big Idea(s)

Chemotaxis is a behavior where cells sense a chemical gradient and respond by moving up the chemical gradient.

When faced with a complex programming challenge it helps to decompose the problem into smaller problems.

Flow charts are an effective way to diagram a program.

When developing a program, it’s helpful to think of it in terms of scenarios, situations that will happen while the program is running, and responses to those scenarios.

Vocabulary words


    • Lego Mindstorm EV3 robot – default assembly (E779, E780, E781, E782, E783, E784, E785) Follow the instructions found here to build (color sensor forward, cuboid, driving base, gyro sensor, medium motor driving base, touch sensor driving base, ultrasonic sensor driving base. Note: EV3’s borrowed from the Resource Center will already be built in the default assembly and will be pre-downloaded with Mystery Program)
    • Chemotaxi Mat (E787)
    • Chemotaxis Program worksheet
    • Chemosense open roberta program
    • Robot Quick Start Guide

Daly Ralson Resource Center:

Lego Mindstorm EV3 robot (E779, E780, E781, E782, E783, E784, E785)

Chemotaxis Mat (E787)


Groups of 3-4 students


3 days

Day 1

15 min – Intro

3 days – Investigation/Coding

1 hour – Final presentation of chemotaxis programs


Prerequisites for students

Students should have experience working with the EV3 robot and programming in Open Roberta. The programming module for this course is required so they are familiar with Open Roberta before starting this activity. The phototaxis program activity is recommended as a pre activity because it establishes scenario-based programming and flow charts as a way to organize programs and computational thinking.

The physarum chemotaxis activity is also a helpful introduction into chemotaxis before starting this activity.

The mystery program is helpful to do before this activity as student often use a variation on the mystery program to keep the robot on the mat.

Learning goals/objectives for students
  • Learn the definition of chemotaxis and ways in which this strategy might be useful to an organism’s survival.
  • Program in terms of “scenarios” and responses to those scenarios
  • Understand and apply the engineering design process of “design, build, test”.
  • Apply engineering problem solving to a programming challenge by identifying a problem and specifying the requirements needed for an authentic solution.
  • Apply programming knowledge to create a chemotaxis program from scratch.
  • Communicate a programming solution using flow charts.
Content background for instructor

One way to think about organizing and developing a program is with “scenario” thinking. At any point during a program, the robot will encounter a set number of scenarios. It is the job of the programmer to identify all scenarios and come up with an appropriate response for the robot in the case of each scenario, so that the robot functions correctly.

Just like there is no one correct program, there is no one correct number of scenarios or responses. Each will vary depending on the program and their design specifications.

Some students may be able to create a chemotaxis program from scratch without this background in programming organization, but to help all students, especially beginners, instructions on how to break the problem down prove very useful.

Getting ready

Share “Chemosense” with all of your students. Make sure all robots have two color sensors, one attached to port 1 and one to part 3. Although it is possible to program a chemotaxis program using only one sensor, it is much easier to use two. Place the chemotaxis mat on the floor with plenty of space around it to allow students to test their program.

Lesson Implementation/Outline


(15 mins)

Let the students know they will be programming their robots to model a cellular behavior known as chemotaxis.  Give the students some background about chemotaxis if they haven’t already done the physarum chemotaxis activity.

Present the chemotaxis mat. The EV3 robots can’t sense chemicals, but they can sense color. We will use the intensity of black as a model for chemical concentration. The students will need to program the robot to detect the color gradient and move toward the highest concentration of black. They will have to start in the “research laboratory” and they must use color, not distance, to move their robot to the darkest spot on the mat.

It is helpful here to talk to the class about how to break down the chemotaxis problem from one big problem to several small problems.  This is modeling computational thinking that engineers and scientists employ all the time.  The breakdown could be as follows:

Problem: Move the robot as close as possible to the darkest spot on the mat.

  • Smaller problems:
    • Which sensor can we use to get the robot to sense the color on the mat?
    • How might the robot use what it senses on the mat to make a movement decision?
    • What scenarios might it encounter?

The first smaller problem will be solved with the color sensor although they may need to do some testing to determine which setting the color sensor should be set to.

The second and third problems are more complicated and it helps to simplify the chemotaxis mat, from a gradient, to a mat with just one white and one black box.  The scenarios and decisions that a robot will make in response to a half white/half black box are much more straight forward:


Scenario 1: both sensors see white and drive forward

Scenario 2: left sensor sees black, right sees white and turn left

Scenario 3: right sensor sees black, left sees white and turn right

Scenario 4: both sensors see black and stop?

(Arguably both scenario 1 and 4 could be programmed similarly where if left and right sensor are equal, the robot drives forward, but scenario 4 could be programmed separately, i.e. when both sensors see black, stop)

What if the mat was not half white and black but could be made up of two shades of gray? How would our program change?

This presentation should hopefully act as a stepping stone to thinking about how to program the robot on a gradient (Remember, at any point in time, each sensor only sees one color as it can only see a small part of the mat).



(3 days)

Allow the students ample time to program their chemotaxis robots. Encourage them to use the Programming Chemotaxis worksheet to guide their thinking. Writing down scenarios helps, along with building a flow chart of the program.

Checking for student understanding

Often students that are experienced in programming will take over, leaving inexperienced programmers behind. Check in with your student groups, watch and listen to how they communicate as they are programming. Ask probing questions like, “How many scenarios are you programming for?” “Do you all agree that those are the only possible scenarios?” “Why did you choose those scenarios?” Check their flow chart if they have one. Remind them that the chemotaxis and phototaxis programs might be very similar.

The mystery program is useful for to keep the robot on the mat for this challenge. Instead of using the ultrasonic sensor, students can program the robot to react (reverse and turn) when it sees green to keep it on the mat.


Have all student groups present their chemotaxis robots after 2 – 3 days of programming. It is more important to have a clear vision (flow chart and scenarios) of their chemotaxis program than to have a working chemotaxis program.

Presentation parts are as follows. It is helpful to randomly assign presentation roles to make sure all group members learn all part of the challenge (i.e. inexperienced programmers do not over rely on the experienced programmers to explain the program in the presentation).

  • Define problem and specify requirements (3 minutes)
  • Final program with flow chart (3 minutes)
  • Robot demonstration (6 minutes)
  • Challenges and lessons learned (3 minutes)

Every group member should be prepared to present any of the parts, as names will be picked at the time of the presentation



Structure and Function

ETS1 Engineering Design

ETS2 Links Among Engineering, Technology, Science, and Society

Performance Expectations

NGSS HS-LS1-3 From Molecules to Organisms: Structures and Processes

(Student model chemotaxis in the robot, a positive feedback loop used in organisms to move towards higher concentrations of food or any other chemical stimulus. Program often feature loops, whereby the robot selects the darker of two regions and moves toward it, ultimately leading the robot to the darkest spot on the mat.)

NGSS HS-ETS1-2 Engineering Design

(Creating a chemotaxis program in a robot is a complex problem. Student are encouraged to break down that problem into smaller more manageable problems.)

NGSS HS-ETS1-3 Engineering Design

(Students must develop their program that is constrained by access to only two color sensors. They can also opt for the additional constraint of programming using only one color sensor. Trade-offs in programming reliability, complexity, and robot design must be taken into account.)

NGSS HS ETS1-4 Engineering Design

(The students are challenged to model chemotaxis, a real cellular behavior, to learn the ways in which this cellular behavior might work in real organisms, like physarum.)

Disciplinary Core Ideas

HS LS1.A Structure and Function

ETS1.A Defining and Delimiting Engineering Problems

ETS1.B Developing Possible Solutions

ETS1.C Optimizing the Design Solution

ETS2.A Interdependence of Science, Engineering, and Technology

(Science and engineering are connected through modeling and designing an observed cellular behavior like chemotaxis. Scientists and engineers collaborate in real cellular engineering labs to modeling cellular behavior in robots.)

Science and Engineering Practices

Practice 1. Asking Questions and Defining Problems

Practice 2. Developing and Using Models

Practice 3. Planning and Carrying Out Investigations

Practice 4. Analyzing and Interpreting Data

Practice 5. Using Mathematics and Computational Thinking

Practice 6. Constructing Explanations and Designing Solutions

Practice 7. Engaging in Argument from Evidence

Practice 8. Obtaining, Evaluating, and Communicating Information

Cross-Cutting Concepts


Cause and effect

Systems and System Models

Structure and Function

Stability and Change