RC Car - Sara Bartles

zSara Bartles

RC Car

Description: Using the motors and basic structure of a old remote control car, I used Ardunio to write a program that would control the car using a wireless remote and chip.

Detailed Description: The program is very simple. I declared four motors and four push buttons. Each button control which motors will turn on. Therefore, if I declare button C to turn on motor 3, the motor 3 would turn on and the wheels would turn right (as long as button A or B was already pushed to put the car in motion.)

What the board looked like:

Program:

int motor1 = 5; /// declares pin5 as motor 1 (Motor that turns Right)

int motor2 = 2; /// declares pin2 as motor 2 (Positive of backmotor)

int motor3 = 3; // declares pin3 as motor 3 (motors that turns left)

int motor4 = 4; // declares pin4 as motor 4 (negative of backmotor)

int A = 6; // declares pin 6 as A

int B = 7; // declares pin7 as B

int C = 13; // declares pin 13 as C

int D = 12; // declares pin 12 as D

int buttonState3 = 0; // declares button states are 0

int buttonState = 0;

int buttonState2 = 0;

int buttonState4 = 0;

void setup()

{

pinMode(motor1, OUTPUT); //declares motors as outputs

pinMode(motor2, OUTPUT);

pinMode(motor3, OUTPUT);

pinMode(motor4, OUTPUT);

pinMode(A, INPUT);

pinMode(B, INPUT); // declares push buttons as inputs.

pinMode(C, INPUT);

pinMode(D, INPUT);

}

void loop() {

buttonState4 = digitalRead(D); //left

buttonState = digitalRead(A); //fwd

buttonState2 = digitalRead(B); //bkw

buttonState3 = digitalRead(C); //right

if (buttonState == HIGH && buttonState2 == LOW) { // says that if A is pushed, and B is not, then the car goes forward

digitalWrite(motor2, LOW);

digitalWrite (motor4, HIGH);

}

if (buttonState == LOW && buttonState2 == LOW) { //says that if A and B is not pushed, then the motors stop

digitalWrite (motor2, LOW);

digitalWrite (motor4, LOW);

}

if (buttonState2== HIGH && buttonState == HIGH) { // says that if B and A is pushed, then the motors turn off

digitalWrite (motor2, LOW);

digitalWrite (motor4, LOW);

}

if (buttonState2 == HIGH && buttonState == LOW) // says that if B is pushed and A is not, then the motors go backwards

{

digitalWrite(motor4, LOW);

digitalWrite(motor2, HIGH);

}

if (buttonState3 == HIGH && buttonState4 == LOW) // says that if C is pushed and D is not, then the car turns right (as long as you have pushed A or B first)

{

digitalWrite (motor3, HIGH);

}

if (buttonState3 == LOW) { // says that if C is not pushed, then turn motor 3 off

digitalWrite (motor3, LOW);

}

if (buttonState4 == HIGH && buttonState3 == LOW) { // says that if D is pushed, then the car turns left

digitalWrite(motor1, HIGH);

}

if (buttonState4 == LOW){ // says that if D is not pushed, than motor 1 is off

digitalWrite (motor1, LOW);

}

if (buttonState4 == HIGH && buttonState3 == HIGH) // states that if both D and C are pushed, than do not turn either motor 1 or 3 on

{

digitalWrite (motor1, LOW);

digitalWrite (motor3, LOW);

}

}

Problems:

Well, apparently my electronics hated me or something, I dunno, because he gave me a broken board and faulty H bridge.

The first problem I encountered was that the car would only sometimes work. Eventually, it stopped working all together and I discovered that my breadboard was falling apart. After I made a new one, the car wouldn't turn left on command. In fact, sometimes it was almost as if pushbutton D reversed all other push buttons. It did unexplainable things (such as figure 8s, serpentine patterns, and speeds changes, even though there was no variable resistor to change the speed), without any buttons being pushed, and, dispute my firm assertion that my car was possessed by a demon and needed a immediate trip to the rectory for an exorcism, I later discovered that the H bridge was not working properly. I did not have a replacement H-Bridge, so I never discovered if it would work properly. The front motor is only one motor, though it has four wires and acts like two separate motors. I never discovered how it works exactly, so that may also be a contributing factor to why the car did not work. It is self centering though, which made my life a whole lot easier.

If I had more time/money, I would make it look cooler and neater. I would add a variable resistor so I could change speeds, led for break lights and head lights, and make the remote control like the ones on the cars at the store for better control. I would also make it look like/call it WALL-E, but that's beside the point.