Robot Car Final

Made by Jake Plona, Alex Scheuer, and Adam Clark
Description: Our project was to make a car that by using a sensor will drive itself and turn when presented with an object it could not drive through.
Description of Program: The program was set up so that the car would move indefinitely forwards until it reached an obstacle that triggered the push button mounted on the front by a whisker. Once triggered the program had the car reverse for one second and then turn for one second.
 
 int motor1 = 12;           //declares the first pin for the first motor
int motor2 = 7;            //declares the second pin for the first motor
int motor3 = 8;            // declares the first pin for the second motor
int motor4 = 13;           // declares the second pin for the second motor
int motorpmw2 = 11;        // this is the first pmw that will set how much battery power the motor is getting (speed)   
int motorpmw = 6;          // this is the second pmw that will set how much battery power the motor is getting (speed)
int button = 2;            // declares the pin for the turn push button
int val = 0;               // declares value for reading sensors

void setup()
{
pinMode(motor1, OUTPUT);           //
pinMode(motor2, OUTPUT);           // these simply are declaring them as outputs
pinMode(motorpmw, OUTPUT);         //
pinMode(motor3, OUTPUT);           //
pinMode(motor4, OUTPUT);           //
pinMode(motorpmw2, OUTPUT);        //
pinMode(button, INPUT);            // declares button as an input
}
 
void loop()
{
  analogWrite(motorpmw2, 255);   // this is the analog speed value for the arduino (0-255)
analogWrite(motorpmw, 255);      // this is the analog speed value for the arduino (0-255)
digitalWrite(motor1, LOW);       //turns the motors on - forwards
digitalWrite(motor2, HIGH);      //
digitalWrite(motor3, LOW);       //
digitalWrite(motor4, HIGH);      //
val=digitalRead(button);         // sets value to be read from the button
if(val == HIGH)                  // this program only takes effect if the button is pushed
{ analogWrite(motorpmw2, 255);   // this is the analog speed value for the arduino (0-255)
  analogWrite(motorpmw, 255);    // this is the analog speed value for the arduino (0-255)
  digitalWrite(motor1, HIGH);    //turns the motors on - backwards
  digitalWrite(motor2, LOW);     //
  digitalWrite(motor3, HIGH);    //
  digitalWrite(motor4, LOW);     //
  delay(1000);                   // does previous direction for one second
  analogWrite(motorpmw2, 255);   // this is the analog speed value for the arduino (0-255)
  analogWrite(motorpmw, 255);    // this is the analog speed value for the arduino (0-255)
  digitalWrite(motor1, HIGH);    //turns the motors on - turns right
  digitalWrite(motor2, LOW);     //
  digitalWrite(motor3, LOW);     //
  digitalWrite(motor4, HIGH);    //
 delay(1000);                   // does previous direction for one second
}
}


Various motor and battery problems were encountered and were fixed by tampering with the circuitry and creating new pieces

Things we would like to add would be a way to control the car without a whisker(such as infrared sensors) and getting a new car base






Comments