TIP THE CAN (TTC) WEEK 1. The class began with a last minute race to try and find a new pair of wheels that would fit the motors. The wheels in the end that we did use are pictured below and provided us the opportunity to take our first few attempts at the tip the can competition.

The following code was used for the TTC competition giving the instructions to rotate on its own axis, pick up a reading for the can, move towards the can and finally once the switch had been pressed to reverse and stop.
// Defining Pins rather than using ints, seems to solve a few issues that were happening
#define button 4 // Switch button
#define echoPin 5 // Trigger Pin for Sensor
#define trigPin 6 // Echo Pin for Sensor
long duration, distance; // Defines variables for duration of pulse, and distance from object
void setup() {
pinMode(trigPin, OUTPUT); // Set up the trigger pin
pinMode(echoPin, INPUT); // Set up the echo pin
pinMode(2, OUTPUT); // Motor 1 Forward
pinMode(3, OUTPUT); // Motor 1 Backward
pinMode(8, OUTPUT); // Motor 2 Forward
pinMode(9, OUTPUT); // Motor 2 Backward
pinMode(button, INPUT); // Switch Voltage Check
}
void loop() {
int push = digitalRead(button); // Setting up var for reading when button is pushed
digitalWrite(trigPin, LOW);
delayMicroseconds(20);
digitalWrite(trigPin, HIGH); // Set trigPin high
delayMicroseconds(20);
digitalWrite(trigPin, LOW); // Send pulse for 20 us
duration = pulseIn(echoPin, HIGH); //pulseIn detects the duration of pulses from trigger
distance = (duration/2)*0.034; // Time to reach object * Speed of Sound in cm/us
if (push == 1) { // Button is Pressed [Hit the Can]
digitalWrite(2, LOW); // Keeps Going Forward for 1 Second
digitalWrite(3, HIGH);
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(2, HIGH); // Goes Backward for 2 Seconds
digitalWrite(3, LOW);
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
delay(2000);
digitalWrite(2, LOW); // Stops for 60 Seconds
digitalWrite(3, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
delay(60000);
}
else { // Button is Not Pressed [Hasn't Hit the Can]
if (distance < 80) {
// Object within Range
digitalWrite(2, LOW); // Goes Forward [Sees Can]
digitalWrite(3, HIGH);
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
}
else {
// Object Out of Range
digitalWrite(2, LOW); // Turns [Default Mode]
digitalWrite(3, HIGH);
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
}
}
delay(50); // Delay to allow ultrasonic reflections to die out
}
Our lecturers provided us with a mock up round platform to emulate the actual competition platform. This gave us an insight into how well our robot worked at this point. Straight away we noticed a grip problem due to the weakness of the motors and the lack of friction on the surface. We decided to use a small rubber piece strapped around the wheels to give it a better hold on the surface and to compromise for the lack of force being applied from the motors. This meant that our test runs were successful from then on and allowed us to make an attempt at a recorded time. Our first try was not a success story due to the fact that when our robot did hit the can it didn’t press the switch in to a point that enabled it to send the message to reverse away. The result was changing what side the switch would slope out from to allow for minimal pressure to be applied on the switch for it to work.
Our second attempt ended up being the time and run we used giving us a great time of 6.24 seconds as can be seen on the screenshot below of the live score sheet for the competition that would run over week 5 and 6. It can be found at this link also (https://docs.google.com/spreadsheets/d/1Tojza0bPpKwD6aS6lRoePU9EUXQcxCEIINZDWM7AKm4/edit#gid=0)

Overall we placed in 4th place with our timing and the fact that we completed our test in week 5/ TTC week 1 meant we would finish above anyone who completed it the following week regardless of there times.
Unfortunately due to unforeseen circumstances the footage of our competition was lost and could not be remade.
(This would have been a benefit for the actual competition however due to the fact it would not be going ahead due to covid 19 this would be the only competition we would be judged on.)