JakeShelleyNick

Jake Case, Shelley Popiel, Nick Posh

Project Name: Robocar

Brief description:

We made a car go forward, hit a wall, and go in reverse by itself. It can also turn.

Detailed description:

The car goes forward according to our code and then when it hits a wall the wire hanging in front touches the aluminum tape on the front bumper of the car. That wire acts like a push button and when it touches the tape the car reverses for two seconds. The front wheels also turn right for one second then turn left for one second during that time. Then after the whole two seconds, it continues forward.

Code:

int motor1 = 2; //declares pin for the first front wheel motorint motor2 = 4; //declares pin for the second front wheel motorint motor3 = 7; //declares pin for the first back wheel motorint motor4 = 8; //declares pin for the second back wheel motor int motorpmw = 9; //declares pmw pin for the speed of the back wheel motorsint motorpmw2 = 10; //declares pmw pin for the speed of the front wheel motors const int buttonpin = 6; //declares pin for the push buttonint buttonState = 0; //declares variable for the button statevoid setup()

{

pinMode(motor1, OUTPUT); //declares the first front wheel motor as an output pinMode(motor2, OUTPUT); //declares the second front wheel motor as an output pinMode(motor3, OUTPUT); //declares the first back wheel motor as an output pinMode(motor4, OUTPUT); //declares the second back wheel motor as an output pinMode(motorpmw, OUTPUT); //declares the pmw pin for the back wheel motors as an output pinMode(motorpmw2, OUTPUT); //declares the pmw pin for the front wheel motors as an ouput pinMode(buttonpin, INPUT); //declares the pin for the button as an input } void loop()

{

analogWrite(motorpmw, 155); //speed of the back wheels is 155 analogWrite(motorpmw2, 155); //speed of the front wheels is 155 buttonState = digitalRead(buttonpin); // if (buttonState == LOW) { //the button is not pushed digitalWrite(motor3, HIGH); //motor3 is on and the other is off making the back wheels go forward digitalWrite(motor4, LOW);

}

if (buttonState == HIGH) { //the button is pushed digitalWrite(motor3, LOW); //motor3 is off and the other is on making the back wheels go backward for 2 seconds digitalWrite(motor4, HIGH);

delay(2000);

digitalWrite(motor2, HIGH); //motor2 is on and the other is off making the front wheels turn right for 1 second digitalWrite(motor1, LOW);

delay(1000);

digitalWrite(motor1, HIGH); //motor2 is off and the other is on making the front wheels turn left for 1 second digitalWrite(motor2, LOW);

delay(1000);

digitalWrite(motor1, LOW); //motor 1 is turned off making the wheels stop turning } }

Problems we encountered:

    1. Wires broke off, we had to solder them back on.

    2. Batteries dying, we got new batteries.

    3. The car sometimes wouldn't work right and we found that some wires were touching or in the wrong spot.

    4. We melted parts of our car accidentally but it didn't matter.

    5. Sometimes our code was wrong so we fixed it.

What we would like to add if we had more time and money:

    1. Paint so we could make it pretty.

    2. Put a squirt gun on it. And a laser pointer. And a parachute so it flies off a cliff.