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-662a2da1445d1869490004/]
Now add inside the[crayon-662a2da1445d8946934155-i/]
[crayon-662a2da1445da329511203/]
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-662a2da1445db160571519/]
Now lets move on into the [crayon-662a2da1445dd852418960-i/]
[crayon-662a2da1445de657762628/]
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-662a2da1445df099632414/]
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-662a2da1445e0807874329-i/]  means “or” it is a boolean operator along with [crayon-662a2da1445e1562755247-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-662a2da1445e2861960668/]
For the right sensor we will type.
[crayon-662a2da1445e3411295836/]
So the right IR sensors are pins 16,17, and 18 if these detect that black line then they will perform this action.
[crayon-662a2da1445e4443499894/]
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-662a2da1445e5519586365/]
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-662a2da1445e6275697921-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-662a2da1445e9609037188/]