Steve, Paul, Kam

Self-Driving Car

Made by Steve DePaulis, Paul Kinder, and Kam Kosowski

Description: Our project was to try to make a car drive by itself and, when presented with an obstacle, will reverse and turn to face a new direction.
Description of program: The program was set up to keep moving forward while the wheels move back and forth and maintain a steady path. When the car runs into an obstacle, it will reverse and turn to face a new direction and proceed to move forward.


int motor1 = 7; // declares the first pin for the first motor
int motor2 = 8; // declares the second pin for the first motor
int motor3 = 12; // declares the first pin for the second motor
int motor4 = 13; // declares the second pin for the second motor
int motorpmw = 10; // declares the pmw pin the will control the power to the motor
int motorpmw2 = 9; // declares the second pmw pin that will control the power to the motor
int button = 2; // declares the pin for the push button
int val = 0; // declares value for reading sensors

void setup()
{
  pinMode(motor1, OUTPUT); // declares them as outputs
  pinMode(motor2, OUTPUT); //
  pinMode(motorpmw, OUTPUT); //
  pinMode(motor3, OUTPUT); //
  pinMode(motor4, OUTPUT); //
  pinMode(motorpmw2, OUTPUT); //
  pinMode(button, INPUT); // declares button as an input
}

void loop()
{
  analogWrite(motorpmw, 255); // analog speed for arduino (0-255)
  analogWrite(motorpmw2, 255); // analog speed for arduino (0-255)
  digitalWrite(motor1, HIGH); // turns the back motors on and makes the car go forward
  digitalWrite(motor2, LOW); //
  digitalWrite(motor3, HIGH); // turns the front motors on and turns right
  digitalWrite(motor4, LOW); //
  delay(500); // delays how long its turned
  digitalWrite(motor3, LOW); // turns the front motors on and turns left
  digitalWrite(motor4, HIGH); //
  delay(500); // delays how long its turned

  val=digitalRead(button); //sets the value that is read by the button
  if(val == HIGH) // this only happens if the button is pushed
  {
    analogWrite(motorpmw, 255); // analog speed for arduino (0-255)
    analogWrite(motorpmw2, 255); // analog speed for arduino (0-255)
    digitalWrite(motor1, LOW); // turns the back motors on and makes the car go backward
    digitalWrite(motor2, HIGH); //
    digitalWrite(motor3, HIGH); // turns the front motors on and turns right
    digitalWrite(motor4, LOW); //
    delay(2000); // delays how long it reverses and turns backward
  }
}


 


Some of the problems that we ran into were that some of the wiring was touching without any insulation which caused the board to malfunction. We had a few troubles with writing the program.

If we had more money, we would make a better push button system that was more effective. I think we would make the board more clean and not have wire everywhere. 






Comments