Week beginning 19/01/2018
From last week we had a working IR line following circuit and a working moisture sensor. However, the two were not connected and neither were mounted to a prototype.
Having bought different motors, that connected easily to wheels, I needed to slightly adapt the circuit we had previously made to cater for the extra power these DC motors required. To do this I took out the voltage regulator and added in a battery pack containing 4 AA batteries. Here is a video of the more powerful DC motor reacting to my TCRT5000 https://www.youtube.com/watch?v=YxujoPZ_owY
Using the line tracking code from before, we needed to turn the moisture sensor into a switch controlling the rest of the code. To do this we created an ‘if’ statement, that if the moisture sensor was wet the code wouldn’t run and if it was dry the robot would track the line towards the sink; to do this I took the basis from a code found at https://randomnerdtutorials.com/guide-for-soil-moisture-sensor-yl-69-or-hl-69-with-the-arduino/
Above, you can see the ‘if’ statement for when the moisture sensor is wet, followed by the ‘else’ statement which triggers the start of the line tracking code. Although this worked, we found that once the sensor was dry and the IR code had started, even if the moisture sensor got wet again the line tracker would continue to run.
We realised that this was because there was no function to be performed when the sensor was wet. Therefore the motors had no other instructions after they had started acting on the IR sensor code. To solve this we added that all 4 motor pins would be low during the ‘if’ statement.
After adding all of this our circuits worked together and the IR circuit was controlled by the moisture sensor, here is a video of our circuit working. As you can see, when the probes are in the mug of water the IR sensor has no impact on the motor. https://www.youtube.com/watch?v=3ox9OfqW_ds
Earlier on in our testing we had noticed that one of our IR sensors was giving us opposite readings to the other, therefore the left sensor was somehow reversing data it was receiving. As we were short on time, instead of properly trying to understand why this was happening, we changed the (! – logical not) part of the left sensor code. This means that it reverses what it does with the data received.
After fixing all of these issues it was time to start building our robot. Because our IR sensors came from different suppliers they have different ranges, therefore they had to be at different heights away from the floor. The left sensor had to be 20mm away from the ground and the right sensor had to be 38mm away, any deviations in this height would mean that the sensors would not function.
Here you can see the different heights in which the sensors are placed.
When we first tried our robot tracking the black line it didn’t work, as you can see in this video ( https://www.youtube.com/watch?v=FdwhN3Oqx-w).
This was because we had positioned our sensors at the back of the car, therefore, by the time the sensors were noticing they had to turn the middle of the car had already passed way over the corner. To change this we swapped what was the front and what was the back of the car, this also meant that we had to change the direction of the wheels. It would be possible ( and not too difficult) to do this by swapping around the HIGH and LOW values on the motors in the code; however, as they are DC motors we also were able to switch the positive and negative wires, thus, changing the direction.
After all these alterations, we had a working prototype!!!
Here are some pictures and videos of the ‘Thirsty Flower Pot’
By Lizzie Spinks