Week 5 : Tip the Can Week 1

26th of February 2020

This week is the Tip the Can Challenge week 1. This challenge required us to programme our robot to find the robotic can, touch it for 1 second, reverse, and stop, while all being timed, using all the parts we had previously worked on. If the can lit a green light, then you have successfully completed the challenge. If the light turns red, then your time is recorded as non compliant.

Tip the Can Ranking Ruled by Ted Burke

Unfortunately, my team did not get to complete the challenge this week as our robot was not functioning properly. Our robot had difficulty locating any object that was placed in front of it and we also had issues with the chassis as our robot kept tipping forward.

We tried to correct the code and change up the chassis but none of that worked. Hopefully next week will work out better.

Tip the Can code week 1

//GROUP 90 TIP THE CAN

int trigPin = 9; //Defining trig pin
int echoPin = 10; //Defining echo pin
long duration, cm, inches;

void setup(){
 Serial.begin (9600);
 pinMode(trigPin, OUTPUT); //Trigpin is an output
 pinMode(echoPin, INPUT); //Echopin is an input
 pinMode(3, OUTPUT); //motors
 pinMode(4, OUTPUT); //motors
 pinMode(6, OUTPUT); //motors
 pinMode(7, OUTPUT); //motors
 pinMode(5, INPUT); //Switch input
}

void loop() {
int x; //switch setup
x = digitalRead(5);
Serial.print("The Switch is now:");
Serial.println(x);

long duration, distance; //defining variables
//pulse from HC-SR04
digitalWrite(trigPin, HIGH); //pulse for 20 micro seconds
delayMicroseconds(20);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2)*0.034;
Serial.print(distance);
Serial.println("cm");
//check echo pulse if less than 20 cm
if (distance <20) {

//(digitalRead(echoPin) == 1)
 digitalWrite(3, LOW); //MOTORS FORWARD
 digitalWrite(4, HIGH);
 digitalWrite(6, LOW);
 digitalWrite(7, HIGH);

 if (x == 1){
 digitalWrite(3, HIGH); //REVERSE
 digitalWrite(4, LOW);
 digitalWrite(6, HIGH);
 digitalWrite(7, LOW);
 delay(2000);

 digitalWrite(3, LOW); //STOP
 digitalWrite(4, LOW);
 digitalWrite(6, LOW);
 digitalWrite(7, LOW);
 delay(60000);

}

}
else {
 digitalWrite(3, LOW); //SCAN MODE, ROBOT RIGHT
 digitalWrite(4, HIGH);
 digitalWrite(6, HIGH);
 digitalWrite(7, LOW);
 delay(250);

 digitalWrite(3, LOW);
 digitalWrite(4, HIGH);
 digitalWrite(6, HIGH);
 digitalWrite(7, LOW);
 delay(250);

 digitalWrite(3, LOW);
 digitalWrite(4, HIGH);
 digitalWrite(6, HIGH);
 digitalWrite(7, LOW);
 delay(250); 
}
}
part of Andrea’s Design
Nathan’s Design

Leave a comment

Design a site like this with WordPress.com
Get started