rc car TO THE EXTREME
We took an ordinary RC car and replaced the controls and brains with our own remote and arduino. it uses 4 pushbuttons to go forward, backward, left, and right. it uses the original 4AA power supply for the motors and a 9V power supply for the arduino.
The car is controlled by a remote control which is acting like a wireless push button. The commands for the remote are being intercepted by the receiver.The receiver then acts as an input to the arduino. The arduino then takes the command and puts it as an output for the H-bridge. the H-bridge regulates the high and the low of the program. The command is caried out by the H-bridge to the motor pins which causes the motor to operate with the remote. It is made wireless by batteries connected to the bread board, and the motors get their power from them. then arduino is powered by the 9 volt.
This is the code we used.
const int motor1Pin = 3; // H-bridge leg 1 (pin 2, 1A)
const int motor2Pin = 4; // H-bridge leg 2 (pin 7, 2A)
const int enablePin = 9; // H-bridge enable pin
const int motor3Pin = 6; // H-bridge leg 1 (pin 2, 1A)
const int motor4Pin = 7; // H-bridge leg 2 (pin 7, 2A)
const int enable2Pin = 5; // H-bridge enable pin
int D = 8; // Declares the pins for the pushbuttons
int C = 10; //
int A = 12; //
int B = 11; //
int buttonState3 = 0; // Declares the base states of the buttons
int buttonState = 0; //
int buttonState2 = 0; //
int buttonState4 = 0; //
void setup() {
// set the switch as an input:
// set all the other pins you're using as outputs:
pinMode(motor1Pin, OUTPUT);
pinMode(motor2Pin, OUTPUT);
pinMode(enablePin, OUTPUT);
pinMode(motor3Pin, OUTPUT);
pinMode(motor4Pin, OUTPUT);
pinMode(enable2Pin, OUTPUT);
pinMode(D, INPUT); // Tells the board to read what is happening to what is attached to this pin
pinMode(C, INPUT); //
pinMode(A, INPUT); //
pinMode(B, INPUT); //
// set enablePin high so that motor can turn on:
digitalWrite(enablePin, HIGH);
digitalWrite(enable2Pin, HIGH);
}
void loop() {
buttonState4 = digitalRead(D);// sets buttonState equal to the digital read
buttonState = digitalRead(C); //
buttonState2 = digitalRead(A); //
buttonState3 = digitalRead(B);//
if (buttonState == HIGH && buttonState3 == LOW) { // says that if C is pushed, and B is not, then the car goes forward
digitalWrite(motor2Pin, LOW);
digitalWrite (motor1Pin, HIGH);
}
if (buttonState == LOW && buttonState3 == LOW ) { //says that if C and B is not pushed, then the motors stop
digitalWrite (motor1Pin, LOW);
digitalWrite (motor2Pin, LOW);
}
if (buttonState == HIGH && buttonState3 == HIGH ) { //says that if C and B is not pushed, then the motors stop
digitalWrite (motor1Pin, LOW);
digitalWrite (motor2Pin, LOW);0
}
if (buttonState == LOW && buttonState3 == HIGH) // says that if B is pushed and C is not, then the motors go backwards
{
digitalWrite(motor1Pin, LOW);
digitalWrite(motor2Pin, HIGH);
}
if (buttonState2 == HIGH && buttonState4 == LOW) // says that if A is pushed and D is not, then the car turns right (as long as you have pushed A or B first)
{
digitalWrite (motor4Pin, HIGH);
digitalWrite (motor3Pin, LOW);
}
if (buttonState2 == LOW && buttonState4 == LOW) { // says that if A is not pushed, then turn motor 3 off
digitalWrite (motor3Pin, LOW);
digitalWrite (motor4Pin, LOW);
}
if (buttonState4 == HIGH && buttonState2 == LOW) { // says that if D is pushed, then the car turns left
digitalWrite(motor3Pin, HIGH);
digitalWrite (motor4Pin, LOW);
}
if (buttonState4 == HIGH && buttonState2 == HIGH) // states that if both D and A are pushed, than do not turn either motor 1 or 3 on
{
digitalWrite (motor3Pin, LOW);
digitalWrite (motor4Pin, LOW);
}
}
Done by Trevor Sibel, Zack Howard, and Logan McCann
Put in $15 for materials
The