### carduinoeducation.com

Carduino

Brief Summary:
We have our arduino and breadboard hooked up so that when the power source is plugged in the motors on the car begin to spin so the car move forwards. Then we have photoresistors plugged in so that the wheels spin when light is blocked and the car then turns. The cars turns away from the light. This should mean that the car should be able to drive itself in theory. https://www.sparkfun.com/products/10825

Detailed Description:
In order to make the motors work we typed in the code with the proper high and low outputs so that both motors would spin the wheels the same way so that the car would move forward. After we had it set up so the car was driving forward we had to make it so it could turn. We had to wire photoresistors so that based on the light sensitivity the car would turn so it wouldn't run into a wall and stop. Once the photoresistors were wired in we had to go to the code and set up an analog read. The analog read would make the motors change from HIGH LOW to LOW HIGH based on the reading the photoresistors were telling the arduino. These changes from HIGH LOW to LOW HIGH would make the car turn.

Fritzing of Carduinoeducation

 ```int motor1 = 2; //declares the first pin for the motor int motor2 = 4; //declares the other pin for the motor int brad1 = 5; int brad2 = 6; int motorpmw = 9; // this is the pmw that will set how much battery power the motor is getting (speed) int bradpmw = 10; int x = 1; void setup() { pinMode(motor1, OUTPUT); // pinMode(motor2, OUTPUT); // these simply are declaring them as outputs pinMode(brad1, OUTPUT); pinMode(brad2, OUTPUT); pinMode(motorpmw, OUTPUT); // pinMode(bradpmw, OUTPUT); Serial.begin(9600); } void loop() { x = analogRead (1); Serial.println(x); if (x>800) { analogWrite(motorpmw, 255); // this is the analog speed value for the arduino (0-255) digitalWrite(motor1, HIGH); digitalWrite(motor2, LOW); digitalWrite(brad1, HIGH); digitalWrite(brad2, LOW); //makes motor go backwards } else if (x<652) {analogWrite(bradpmw, 255); // this is the analog speed value for the arduino (0-255) digitalWrite(brad1, LOW); digitalWrite(brad2, HIGH); //turns the motors on - forwards digitalWrite(motor1, LOW); digitalWrite(motor2, HIGH ); //makes motor go backwards } else {analogWrite(motorpmw, 255); // this is the analog speed value for the arduino (0-255) digitalWrite(motor1, LOW); digitalWrite(motor2, HIGH); analogWrite(bradpmw, 255); // this is the analog speed value for the arduino (0-255) digitalWrite(brad1, HIGH); digitalWrite(brad2, LOW); //turns the motors on - forwards } } ```

Problems that we encountered while making our car were first making the motors both spin the same way, then getting the analog to work was another problem. After we got the analog read to work we had a problem figuring out the code so the car would back up. Most of the problems we had were with the code but the one problem we did have wiring wise was the wiring of the photoresistors.

If we had more time we would've wanted something to put on the front of the car so that if it ran straight forward into a wall it could back itself up and turn. If we had more money we would've wanted to buy a real car and then put arduino on that.