How to Program the Sumo Bot

This lesson will go over how to program the Sumo Bot

What it Does?

It stays within the circle, but we can potentially program it to push objects outside of the circle or even compete with other robots. In this section, we will focus on staying within the circle, but if you would like to learn more about upgrading it, click here.


Check the bottom two IR sensor on the left and right sides:

  1. If the left one sees a line, backup and turn right.
  2. If the right one sees a line, backup and turn left.
  3. Otherwise go forward.

We are going to start with the setup code. We will need to include the SmartInventor library at the top of the code. Then since we will be needing the motors to move us around, we will need to set them up.

Next we need to setup the sensors we are going to be using. We will use the bottom left and bottom right sensors to see the line, so we need to set them up.

Next we need to read the sensors and save the values so that we can check their values.


Now it is time to write the main section of the code. In order to do so, we will use an “if statement” to check whether the sensors have detected the black line (they reads LOW). If you need a reminder on how “if statements” work,  you can watch one of our videos (here).

In the following example, we will evaluate the left sensor. If it see the black line (it reads LOW) we will have it back away, and then turn away from the line.

Similarly, we have to consider the case when the right sensor detects a line using an “else if” statement. This time it should backup and turn left instead:

And finally, using an “else” statement, we can direct the robot to go forward if no black lines were detected:

Optional: In order to customize the robot’s actions, you may change the speed or the delay time.

Final Code