After further experimenting with the hardware I've got 4 wires connected to four different solder points on the circuit board. Which in turn have been connected to the Arduino.
When I Output HIGH to Pin 8, the car goes forward.
When I Output HIGH to Pin 7 and 8, the car goes reverse.
When I Output HIGH to Pin 13, the car goes left.
When I Output HIGH to Pin 12 and 13, the car goes right.
Great. But..When I try to use all the pins together in my code, it doesnt work.
So this works
void off() {
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
}
void setup() {
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
//pinMode(12, OUTPUT);
//pinMode(13, OUTPUT);
off();
}
void goForward() {
digitalWrite(8, HIGH);
}
void goReverse() {
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
}
void loop() {
goForward();
delay(1000);
off();
goReverse();
delay(1000);
off();
}
But this wont work. All I did was set 12 and 13 as Output pins and the car will go only in the forward direction without any delay. Perhaps it gets stuck in the goforward function loop?
void off() {
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
}
void setup() {
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
off();
}
void goForward() {
digitalWrite(8, HIGH);
}
void goReverse() {
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
}
void loop() {
goForward();
delay(1000);
off();
goReverse();
delay(1000);
off();
}