How to Implement the Bottom IR Sensors on the Sumo Bot

The Sumo bot is able to stay within the arena as long as the bottom Infrared Sensors (IR) are close to the ground. In this lesson you will learn how to calibrate and use more of the bottom IR sensors to stay in the field.

Begin the code by including the following

Now add inside the void setup()

These are all the IR sensors the smart inventor board has. If you count all the bottom IR sensor you will find out that there are only 7 even though here it is listed as 8, this is because 14 and 15 are tied to the same bottom IR sensor which is the center one.

Now we will initialize the motors.

Now lets move on into the  void loop()

So now we will implement all the bottom left IR sensors. These are IR sensor 11,12 and 13. So lets create an If statement that will be activated whenever 11,12 or 13 IR sensors detect that the line is present which will make the sensor go LOW.

This piece of code can be read as “if pin 11 is low, or if pin 12 is low, or if pin 13 is low “. The  ||  means “or” it is a boolean operator along with  &&  which means “and” they are used as logical operators.

So if any of the left IR sensors detect the black ring then do the following

For the right sensor we will type.

So the right IR sensors are pins 16,17, and 18 if these detect that black line then they will perform this action.

Once both the left and right IR sensors have been checked the only other case is if none of them are detecting the competition ring. So now type.

So this if statement checks every pin connected to all the sensors using the digital read command.The code reads “if pins 11 is HIGH and if pin 12 is HIGH and ….if pin 18 is HIGH” where the &&  stands for “and”. If all of them are HIGH, the robot is within the field so the Sumo bot should drive at full speed ahead.

Now that you are done programming the sensitivity can be adjusted for the IR sensors. The robot at times may be to sensitive and the sun will interfere with it and activate the IR sensor. Just adjust the white cross (potentiometer) with a screw driver in order to adjust the sensitivity until the robot detects the line properly.


Final Code