# The Carduino

HOW IT WORKS

THE Carduino was done by the historic duo of Brad "the Real" Popiel and Dan "the Man" Kerry. We used a chassis for the body of the car, then two motors. For our project, we created a self-driving car that had "push buttons" on the front of it. Whenever the car would hit something, one of the "push buttons" would be hit and would send the car backwards, and then the car would turn away from the obstacle it initially hit. THE Carduino program works by having an internal code that tels the motors of the car to go straight unless, if one of the push buttons is hit, then it sends signal for the motors to back up and turn away from the object. When the motors are on HIGH to LOW, they go straight. When its LOW to HIGH, the car moves backwards.

PICTURES

CODE

int motor1 = 2; //declares the first pin for the motor

int motor2 = 4; //declares the other pin for the motor

int motorpmw = 9; // this is the pmw that will set how much battery power the motor is getting (speed)

int motor3 = 10; //declares the first pin for the motor

int motor4 = 6; //declares the other pin for the motor

int motorpmw1 = 13; //pmw that will set how many battery power the motor will get

int pushbutton1 = 11; //decalres the pin for pushbutton1

int pushbutton2 = 4; //declares the pin for pushbutton2

void setup()

{

pinMode(pushbutton1, INPUT); //declares pushbuttons as inputs

pinMode(pushbutton2, INPUT); // declares pushbuttons as inputs

pinMode(motor1, OUTPUT); // declares as output

pinMode(motor2, OUTPUT); // these simply are declaring them as outputs

pinMode(motorpmw, OUTPUT); //declares as output

pinMode(motor3, OUTPUT); //declares as output

pinMode(motor4, OUTPUT); // these simply are declaring them as outputs

pinMode(motorpmw1, OUTPUT); // declares as output

}

void loop()

{

analogWrite(motorpmw1, 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 motor off- backwards

digitalWrite(motor2, LOW); //turns the motors on - forwards

digitalWrite(motor3, HIGH); // turns motor off- backwards

digitalWrite(motor4, LOW); //turns the motors on - forwards

delay(10);

if (digitalRead(11) == HIGH) //if statement if puch button is hit

{

digitalWrite (motor1, LOW); //turns the motors on - forwards

digitalWrite (motor2, HIGH); // turns motor off- backwards

digitalWrite (motor3, LOW); //turns the motors on - forwards

digitalWrite (motor4, HIGH); // turns motor off- backwards

delay (500); // backs up fpr half second

digitalWrite (motor3, HIGH); // turns motor off- backwards

digitalWrite (motor4, LOW); //turns the motors on - forwards

delay (500); // turns to the right for half second

}

if (digitalRead(5) == HIGH) //if statement if push button is hit

{

digitalWrite (motor1, LOW); //turns the motors on - forwards

digitalWrite (motor2, HIGH); // turns motor off- backwards

digitalWrite (motor3, LOW); //turns the motors on - forwards

digitalWrite (motor4, HIGH); // turns motor off- backwards

delay (500); // backs up half second

digitalWrite (motor1, HIGH); // turns motor off- backwards

digitalWrite (motor2, LOW); //turns the motors on - forwards

delay (500); //turns to the left for half second

}

}