Line Tracking Robot: PDP

We began the project by listing the components we deemed essential. One of the main components being two IR sensors which function using Digital Pins, allowing us to observe when they were ‘HIGH’ or ‘LOW’ using the digital read function on the serial monitor. For us to test the IR sensors we had to write our first code:

 int leftSensor = 7;
int rightSensor = 8;

void setup() {
Serial.begin(9600);
pinMode(leftSensor, INPUT);
pinMode(rightSensor, INPUT);
}

void loop() {
int sensorValL = digitalRead(leftSensor);
int sensorValR = digitalRead(rightSensor);
Serial.println(sensorValL);
Serial.println(sensorValR);
delay(1);
}

IR Sensors

We discovered from this test that the IR sensors must be 20mm from the floor to work at their best.

We chose to include a free moving wheel at the front of the racer, this uses less energy than a servo operated wheel and is light weight. L298N motor controller was also used, as it is easy to control the speed (which is controlled using Pulse Width Modulation pins on the Arduino) and direction (each motor is connected to an additional two digital pins that control the direction through simple LOW / HIGH code combinations). A 9v battery will be used to power the Arduino through the motor controller. The motor controller is necessary because one motor will not consume much current, but can’t move a large mass whereas as two motors can move a large mass but will consume a large current. 

1

Before we could test how effective these components were, we needed a working code. I was proud that we wrote our code ourselves, with research we figured out the issues and we both learnt from the experience.

 

//motor controls
//left motor
int enableA = 10;
int in1 = 9;
int in2 = 8;

//right motor
int enableB = 5;
int in3 = 7;
int in4 = 6;

//sensor pins

int leftSensor = 4;
int rightSensor = 3;

void setup() {
Serial.begin(9600);
pinMode(enableA, OUTPUT);
pinMode(enableB, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(leftSensor, INPUT);
pinMode(rightSensor, INPUT);

}

void loop() {
int leftSensorValue = digitalRead(leftSensor);
int rightSensorValue = digitalRead(rightSensor);
boolean leftSenDetect = digitalRead(leftSensor);
boolean rightSenDetect = digitalRead(rightSensor);

//testing sensor values and distance required from ground

Serial.print(“left sensor = “);
Serial.println(leftSensorValue);

Serial.print(“right sensor = “);
Serial.println(rightSensorValue);

//false is if surface is DARK!
//true is if surface is LIGHT!

if (leftSenDetect == true && rightSenDetect == true) {
//left motor direction
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);

//left motor speed
analogWrite(enableA,200);

//right motor direction
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);

//right motor speed
analogWrite(enableB, 200);
}

else if (leftSenDetect == false && rightSenDetect == true) {

// keep left motor going
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);

//left motor speed

analogWrite(enableA, 75);

// stop right motor
digitalWrite(in3, LOW);
digitalWrite(in4, LOW

delay(550);

analogWrite(enableB, 100);

}

else if (leftSenDetect == true && rightSenDetect == false) {
// stop left motor
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);

analogWrite(enableA, 100);

// keep right motor going
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);

delay(550);

analogWrite(enableB, 75);

}

}

 We made our first model out of 6mm MDF board, it was simply just a rectangle on wheels but it allowed us to test what we needed it and then learn from that and then develop it. We attached the components to the 140mm by 70mm piece of MDF using BlueTrack, as it attached them temporarily making it quick to disassemble and reassemble which was creating for testing. We tested this model on a simple track, we realized after the first test that changes to our code were necessary, such as adding a delay to the ‘else if’ statements, giving the Racer more time to correct itself. After this we created a more complex track, after changing the code again so that the delay was set at 500 milliseconds and altering the positioning of the IR sensors it followed the line on this track.

We also noticed that the wheels that were laser cut from 6mm MDF lacked traction, causing wheel spin. We solved this by attaching elastic bands. We experimented with two different wheel sizes after this, one set had a 40mm diameter and the other 60mm. We calculated the speed of these wheels using Speed = Distance/Time. The 40mm wheels completed the track 2-meter straight track in 0.13 meters per second, and the 60mm did the track in0.22 meters per second. This result proved that the larger the feel the faster the Racer since it covers more ground per rotation. We then tested acceleration using the formula acceleration=velocity/time taken. The 40mm Wheels had an acceleration of 0.0244 m/s2, whereas the 60mm Wheels had an acceleration of 0.0086 m/s2. Finally, we calculated the force required for each size (Force = Mass X Acceleration). The mass of the Racer was 250g giving the 40mm wheels a force of 0.0061N, and the 60mm wheels a force of 0.00215 N. The larger wheel increased acceleration meaning less force is needed, increasing the efficiency of the Racer. Therefore we chose to use larger wheels in the final model.

2

For our second model, we used 3mm Plywood, because of it being a less dense material and 3mm thinner it would make the Racer lighter. We also added a switch, and used 80mm diameter wheels, added supports on the outer side of the wheels to keep them straight, and an extra level so that there would be more space for the components and an underside to hide and organize the mess of the wires. This extra layer would be supported by a Warren Girder Bridge arrangement, as it is effective and light weight.

Due to changes in the Racer, the code needed altering. Delays were reduced due to larger wheels, one wheel turns in the opposite direction to achieve sharper turns, and we set the motors to 220 on the PWM pins when neither of the sensors are detecting the black lines which really helped in producing a noticeable improvement in speed.

//left motor controls
int enableA = 10;
int in1 = 9;
int in2 = 8;

//right motor
int enableB = 5;
int in3 = 7;
int in4 = 6;

//sensor pins

int leftSensor = 4;
int rightSensor = 3;

void setup() {
Serial.begin(9600);
pinMode(enableA, OUTPUT);
pinMode(enableB, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(leftSensor, INPUT);
pinMode(rightSensor, INPUT);

}
void loop() {
int leftSensorValue = digitalRead(leftSensor);
int rightSensorValue = digitalRead(rightSensor);
boolean leftSenDetect = digitalRead(leftSensor);
boolean rightSenDetect = digitalRead(rightSensor);

//testing sensor values

Serial.print(“left sensor”);
Serial.println(leftSensorValue);

Serial.print(“right sensor”);
Serial.println(rightSensorValue);

// false is dark surface
//true is light surface

if (leftSenDetect == true && rightSenDetect == true) {
//left motor direction
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);

analogWrite(enableA, 220);

// right motor

digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);

analogWrite(enableB, 220);
}

else if (leftSenDetect == false && rightSenDetect == true) {

// left motor opposite way
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);

analogWrite(enableA, 50);
//right motor speed
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);

analogWrite(enableB, 70);

delay(350);

}
else if (leftSenDetect == true && rightSenDetect == false) {
// left motor speed
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);

analogWrite(enableA, 70);

// right motor opposite way

digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);

analogWrite(enableB, 50);

delay(350);

}
}

The speed of this Racer was 0.11 meters per second faster than the previous racer. The acceleration increased by 0.0464 m/s2. And with a weight of 350 grams an additional 0.0171 N of force was required.

20170324_125218

We chose to return to MDF for the final model because the Plywood warped. But we chose to include slots on the top layer for cable management and a slot for the switch to sit into.

We designed a place for the Egg to sit, we decided to take the name ‘Dream Ender’ and create ‘Dream Ender II’. We went with the theme of this name creating a Devil seat for the egg, and engraved the seat and wheels with this name.

We purchased an Arduino Nano, since they would take up less space and be lighter in comparison to a regular sized Arduino. But it drained all power for the motors, we are unsure if this was due to them being so cheap, or if the soldering caused it damage. But because of this we had to return to the original Arduino, and we were unable to shed a potentially significant amount of weight.

This time it weighed around 325 grams, we expected this due to the extra weight of the egg support and the use of MDF. Surprisingly, the speed was reduced slightly by 0.02 meters per second. We believe this could be due to one of the wheels not being completely straight, to help fix this we added pieces of plywood for support and stability. The acceleration decrease by 0.006-meter m/s2. And due to the lighter weight, it took 0.003325 N less force to move the Racer and the cost of a slightly reduced speed, therefore there was no real increase in efficiency.

20170330_175307 1

20170330_175230

20170330_175237

We tested this Racer on a simple track and completed it flawlessly. Therefore, we created the most complex track we had yet, with very sharp turns. Unfortunately, the racer did not always make these turns so we reduced the speed and delays out of fear that it may stray from the track on the day of the race. We also added code that would make the Racer stop when both sensors were above the black tape.

Line Tracking Robot Racer- The final model

We reviewed the second model together ready to plan for our final Racer!

The first thing we noticed was that using Plywood for the body was not as successful as we had hoped, this material is prone to warping, and when this happens it will cut inaccurately in the laser cutter and disfigure the final shape, so we decided to return to MDF.

Secondly, we needed to fully arrange the wires this time so that they are neatly organised making it more aesthetically pleasing and understandable. We wish to achieve this by cutting slots into the top MDF layer, for the wires to be pulled through. We also chose to solder down some wires for more reliable contact.

We also cut a section out of the top MDF layer for the Switch to slot into, this made huge improvement to the aesthetic and ease of use for the switch.

And finally we designed a place for the Egg to sit, we decided to take the name from the elastic band racer ‘Dream Ender’ and create ‘Dream Ender II’. We went with the theme of this name creating a Devil seat for the egg, and engraved the seat and wheels with this name.

We purchased a few Arduino Nanos, since they would take up less space and be lighter in comparison to a regular sized Arduino, but for some reason they drained all power for the motors, we are unsure if this was due to them being so cheap, or if the soldering caused them damage. Because of this we had to return back to the orginal Arduino therefore were unable to shed a potentially significant amount of weight. This time it weighed around 325 grams, we expected this due to the extra weight of the egg support and the use of MDF.

20170330_165739

Speed:

We returned back to the 2 meter track for the final time, sett the PWM (pulse width modulation) pins to 255 to calculate the speed.

Speed = Distance / Time

Speed = 2 / 6.31

Speed = 0.31 meters per second

Surprisingly, the speed was reduced slightly by 0.02 meters per second. We believe this could be due to one of the wheels not being completely straight, to help fix this we added pieces of plywood for support and stability.

Acceleration=

Acceleration = 0.049 meter / square second {m/s2}

80mm Wheels Acceleration = 0.055 meter / square second {m/s2}

A decrease in 0.006 meter / square second {m/s2}

Force 

Looking at the force required to move the object.

Force = Mass X Acceleration

Force = 0.325 x 0.049

Force = 0.015925 N

Due to the lighter weight, it took 0.003325 N less force to move the Racer and the cost of a slightly reduced speed, therefore there was no real increase in efficiency.

We tested the Racer on our track after testing it on the 2 meters. It finished it flawlessly, so we chose to create a more complex track with sharp corners, as we were unsure on what we would be facing on the day. Unfortunately, the racer did not always make these sharp corners , so we reduced the speed and delays to be safe. We also coded the racer so that it was stop completely when both sensors faced the black tape (therefore will stop at the finish line).

If we were to do this again we would used more sensors, designed and made much more stable wheels, and a more pleasing aesthetic.

Line Tracking Robot Racer: The 2nd Model and testing

On this model, the Racer traveled in a straight line due to the wheel supports making it much easier to test. We used the 2 meter track previously used and timed it to gather the same data recorded from the last model (speed, acceleration and force).

Speed: We used the time it took for the Racer to finish the 2 meter track to calculate the speed, (the racer finished the track in 6 seconds).

Speed = Distance / Time

Speed = 2 / 6

Speed = 0.33 meters per second

An increased speed of  0.11 meters per second.

Acceleration: 

After calculating the change in velocity we worked out the acceleration. Acceleration had also improved.

 

80mm Wheels Acceleration = 0.055 meter / square second {m/s2}

An increase in acceleration by 0.0464 meter / square second {m/s2}

Force 

I order to calculate the force we reweighed the racer (including the egg this, as that will be included on the day of the race). The racer weight 350 grams, which is another 100 grams. Although we decreased the thickness of material and chose a less dense material, the amount of material to create the extra layer and structural support was added, so we expected an increase in weight overall.

20170324_122905

Force = mass X acceleration

Force = 0.35(kg) X  0.055 (m/s2)

Force = 0.01925 N

An additional 0.0171 N of force was required.

 

Changes in the code were required for the Racer to move most efficiently due to the change in the Racers body.

  • Delays could be reduced due to the wheels being larger.
  • One wheel now turns in the opposite direction in order to achieve sharper turns.
  •  We set the motors to 220 on the PWM (pulse width modulation) pins when neither of the sensors are detecting the black lines which really helped in producing a noticeable improvement in speed.
Fastest Code So Far

Here we have the best code yet, I feel we’re nearing the sweet spot in terms of speed and reliability.

//left motor controls
int enableA = 10;
int in1 = 9;
int in2 = 8;

//right motor
int enableB = 5;
int in3 = 7;
int in4 = 6;

//sensor pins

int leftSensor = 4;
int rightSensor = 3;

void setup() {
Serial.begin(9600);
pinMode(enableA, OUTPUT);
pinMode(enableB, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(leftSensor, INPUT);
pinMode(rightSensor, INPUT);

}
void loop() {
int leftSensorValue = digitalRead(leftSensor);
int rightSensorValue = digitalRead(rightSensor);
boolean leftSenDetect = digitalRead(leftSensor);
boolean rightSenDetect = digitalRead(rightSensor);

//testing sensor values

Serial.print(“left sensor”);
Serial.println(leftSensorValue);

Serial.print(“right sensor”);
Serial.println(rightSensorValue);

// false is dark surface
//true is light surface

if (leftSenDetect == true && rightSenDetect == true) {
//left motor direction
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);

analogWrite(enableA, 220);

// right motor

digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);

analogWrite(enableB, 220);
}

else if (leftSenDetect == false && rightSenDetect == true) {

// left motor opposite way
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);

analogWrite(enableA, 50);
//right motor speed
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);

analogWrite(enableB, 70);

delay(350);

}
else if (leftSenDetect == true && rightSenDetect == false) {
// left motor speed
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);

analogWrite(enableA, 70);

// right motor opposite way

digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);

analogWrite(enableB, 50);

delay(350);

}
}

Line Tracking Robot Racer: What we learnt from our first model

Having tested a Sketch model with and without the egg (as the added mass of the egg would obviously effect the force), we were provided with a new and useful set of information that we could apply to our next model and iteration of code in order to make it better.

The first and most obvious thing to us that needed to be changed from the first model was the material, and the thickness of the material used in the main body. Instead of 6mm MDF we have chosen to test 6mm Ply, this is because we want to make the Racer lighter increasing its speed, and MDF is a very dense material.

Another issue we found with our Racer was that was that it was difficult to turn the Racer on and off as we would have to remove wires in order to do so. So we would like to add an on/off switch to provide easier operation.

As discussed in previous blog posts we discovered that the larger the wheel, the faster the car, therefore we have decided to increase the diameter by another 20mm in diameter (80mm), we have purchased gears that we will use if the increased wheel size does not speed up the car as fast as we would like. The only issue we had with the 60mm wheels on the last model was that they were not travelling straight. When testing the Racer on a straight 2m track with a code telling the Racer to dive forward, the Racer began to drive to the left, so next time we will add supports on the outer side of the wheel,

Our previous Racer last wasn’t the most aesthetically pleasing thing, mainly due to the mess of wires, therefore in this iteration we want to try and increase cable management. One way in which we wish to try and achieve this is by adding another layer onto the Racer for components to be secured to, having this will allow us to hide the wires on the lower layer. On the lower layer we plan to secure the two motors at the near end, the top layer will sit on top of this, therefore the motors will also at as a a support. Although, support was still needed for the front end of the Racer, we discussed possible solutions and decided that the Warren Girder Bridge arrangement seemed the best solution as it is supportive and a lightweight efficient solution, so we shall trial this out using 3mm Plywood for the panels.

warren1

 

Line Tracking Robot Racer: Wheel Testing (Speed, Acceleration and Force)

The next component on our list was the wheels. We had previously discussed the possibility of including 3D printed tracks as a replacement, but decided against this as wheels would be easier and faster to test and change or alter if necessary, and also gives us the option to experiment with gears. We experimented with two different wheel sizes by laser gutting them quickly out of plywood and calculating the speed for each journey using the formula speed =distance/time. 

We wrote new code to test the wheels, making sure that the Racer only moved forwards. We marked a two meter track and then timed how long (time) it took for the Racer to finish the two meter (distance) track.
40mm Wheels completed the 2 meters in 15 seconds.

60mm Wheels completed the 2 meters in 9 seconds.

Calculations for working out the speed for each set of wheels:

Speed=Distance/Time

40mm :

speed = 2 / 15

0.13 meters per second

60mm :

speed = 2 / 9

0.22 meters per second

From this we learnt that the larger the diameter of the wheel the faster the rotation, this confirms what we were taught in one our mechanical engineering lecture that the more ground per rotation increased speed.

We chose to carry on using elastic around both wheels for added traction, the same way as we did on the previous sketch model. Due to the increased size in wheels increasing the speed of the Racer, it has been necessary to reduce the delay function in the coding.

After testing the speed of the wheels we chose to calculate acceleration, which is change in velocity/time taken

60mm Wheels =0.0086 meter / square second {m/s2}

40mm Wheels = 0.0244 meter / square second {m.s2}

Finally we wanted to work out the force depending of the size of the wheels, in order to work this out we needed to weight the Racer, the weight was 250g.

20170317_102020

Force = Mass X Acceleration

60mm Wheels :

Force = 0.25(kg) X 0.0086(m/s2)

Force = 0.00215 N

40mm Wheels:

Force = 0.25 X 0.0244

Force = 0.0061 N

Due to a larger acceleration

The larger wheel increases acceleration meaning less force is needed, increasing the efficiency of the Racer.  Therefore, we shall use larger wheels in the final model.

Line Tracking Robot Racer: Further Component Analysis

We returned back to the components list after familiarising ourselves with the infrared sensors. We wanted to think outside the box when it come to the components we included in our design so that it was unique in comparison to the many other Robot Racers online. One unique idea for components we had was using a free moving wheel at the front of the racer, this not only add a quirky look and function but it would also use less energy than a servo operated wheel and is also lighter in weight. We will decided whether it will be included on the final design after testing it on a prototype model. But before we can test this free moving wheel and other components we need a working code.

There are a list of component that were given to us that need to be included in our design including two dc motors and a servo motor. We were also given a choice of motor controllers, we chose to include the L298N. From previous research, this motor controller seems perfect for what we are trying to achieve as it is simplistic and easy to control the speed (which is controlled using Pulse Width Modulation pins on the Arduino) and direction (each motor is connected to an additional two digital pins that control the direction through simple LOW /  HIGH code combinations). A 9v battery will be used to power the Arduino through the motor controller. The motor controller is necessary because one  motor will not consume much current, but can’t move a large mass whereas as two motors can move a large mass but will consume a large current. 

motor controllertesting motors

We realised from previous testing with the IR sensors that for them to work at there best they needed to be approximately 20mm from the floors surface due to shadowing and reflection from the light source on the sensor which would provide an inaccurate reading.

As mentioned in the previous blog post the idea is that we could attach the digital sensors to each side of the car and they will then hopefully they will be able to sense the light difference between the flooring and the black tape, and will always be able to correct itself so that the black tape is kept in between the two sensors. Therefore the Racer will be able to follow the line. Depending on which sensor detects the tape, either the left or right motor will switch off so that the robot will correct itself.

1

The Code:

//motor controls
//left motor
int enableA = 10;
int in1 = 9;
int in2 = 8;

//right motor
int enableB = 5;
int in3 = 7;
int in4 = 6;

//sensor pins

int leftSensor = 4;
int rightSensor = 3;

void setup() {
Serial.begin(9600);
pinMode(enableA, OUTPUT);
pinMode(enableB, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(leftSensor, INPUT);
pinMode(rightSensor, INPUT);

}

void loop() {
int leftSensorValue = digitalRead(leftSensor);
int rightSensorValue = digitalRead(rightSensor);
boolean leftSenDetect = digitalRead(leftSensor);
boolean rightSenDetect = digitalRead(rightSensor);

//testing sensor values and distance required from ground

Serial.print(“left sensor = “);
Serial.println(leftSensorValue);

Serial.print(“right sensor = “);
Serial.println(rightSensorValue);

//false is if surface is DARK!
//true is if surface is LIGHT!

if (leftSenDetect == true && rightSenDetect == true) {
//left motor direction
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);

//left motor speed
analogWrite(enableA,200);

//right motor direction
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);

//right motor speed
analogWrite(enableB, 200);
}

else if (leftSenDetect == false && rightSenDetect == true) {

// slow down left motor speed
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);

//left motor speed

analogWrite(enableA, 75);

//maintain right motor speed
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);

delay(550);

analogWrite(enableB, 100);

}

else if (leftSenDetect == true && rightSenDetect == false) {
//maintain left motor speed
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);

analogWrite(enableA, 100);

//slow down right motor
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);

delay(550);

analogWrite(enableB, 75);

}

}

2

 

This was basic prototype to test the functions of the model, although it lacked aesthetic quality to allowed us to test what we needed to. the base consisted of a 140mm X  70mm MDF board, and the components were attached to this with a range if blue tack, glue and double sided tape. These temporary attachment methods were useful for quick disassembly, in order to find the best position for the components.

Testing this prototype also made us aware of changes that needed to be made in the code, for example, we added a delay to the “if else” statements, giving the Racer more time to correct itself when turning sharp corners, due to this testing the delay has been set at 550 milliseconds, but this is open to change in further testing.

The first track we tested the model on was simplistic with minimal sharp corners, but since we are unsure on what the track will be like on the day, we created a more complex track once the car could follow the line on the first track.

tac1

There were a lot more issues with the second track (displayed below). The corners were so sharp that the Racer didn’t have enough delay time to sense the black line therefore it would leave the track. We altered the code and positioning of the sensors and after numerous attempts managed to get the Racer to follow it.

trac2

The laser cut wheels that were cut from the 6mm MDF lacked grip, this caused wheel spin when having one motor on and the other off. We solved this by using elastic bands to increase the traction greatly on the wheels.

 

Line Tracking Robot Racer- Experimenting with IR Sensors

To conclude level 5 Engineering science we have been asked to combine our knowledge of Programming and Electronics and Mechanical Engineering, and apply them to efficiently design and make a device that can complete a 10-meter course by tracking a line whilst carrying a raw egg.  

We began by creating a list of components which we thought we would need to create an accurate and fast moving line tracking robot. Out of all the components our first priority was selecting the most accurate sensor for the job we were facing. We came to the conclusion that using two IR sensors would work well. We could attach the digital sensors to each side of the car and they will then hopefully they will be able to sense the light difference between the flooring and the black tape. Therefore the Racer will be able to follow the line.

The IR sensors function using digital pins, therefore we can use the digital read function to see if they are  HIGH or LOW using the serial monitor. This was extremely useful in the development of our Racer design as it gave as an idea of how sensitive the sensors were the the light and dark floor surfaces, providing us with the essential information of how high from the floor surface the sensors would need to be to work. We wrote some basic code in order for us to test this:

int leftSensor = 7;
int rightSensor = 8;

void setup() {
Serial.begin(9600);
pinMode(leftSensor, INPUT);
pinMode(rightSensor, INPUT);
}

void loop() {
int sensorValL = digitalRead(leftSensor);
int sensorValR = digitalRead(rightSensor);
Serial.println(sensorValL);
Serial.println(sensorValR);
delay(1);
}

IR Sensors