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
[crayon-670b0f81227ef667904108/]
Now add inside the[crayon-670b0f81227f5139316205-i/]
[crayon-670b0f81227f6421387871/]
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.
[crayon-670b0f81227f7057799296/]
Now lets move on into the [crayon-670b0f81227fa880292459-i/]
[crayon-670b0f81227fb545994448/]
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.
[crayon-670b0f81227fc598666200/]
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 [crayon-670b0f81227fd753462491-i/]  means “or” it is a boolean operator along with [crayon-670b0f81227fe895184678-i/]  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
[crayon-670b0f81227ff302371011/]
For the right sensor we will type.
[crayon-670b0f8122800548089797/]
So the right IR sensors are pins 16,17, and 18 if these detect that black line then they will perform this action.
[crayon-670b0f8122801445481829/]
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.
[crayon-670b0f8122802405516038/]
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 [crayon-670b0f8122803022437410-i/]  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
[crayon-670b0f8122806209346223/]