Hello I have an RC car which has two 3v motors (one for left/right and the other one for forward/back). The left and right motor is working fine but when I try to rotate the other motor it rotates only back. I've tried the motor separately and it works in both direction without the controller.
My code is the following:
int enablePinMotorAF = 3;
int in1PinMotorAF = 5;
int in2PinMotorAF = 6;
int enablePinMotorLR = 11;
int in1PinMotorLR = 10;
int in2PinMotorLR = 9;
boolean reverse = true;
void setup() {
pinMode(enablePinMotorAF, OUTPUT);
pinMode(in1PinMotorAF, OUTPUT);
pinMode(in2PinMotorAF, OUTPUT);
pinMode(enablePinMotorLR, OUTPUT);
pinMode(in1PinMotorLR, OUTPUT);
pinMode(in2PinMotorLR, OUTPUT);
}
void loop() {
//go forward ->not working
analogWrite(enablePinMotorAF, 230); //max speed
digitalWrite(in1PinMotorAF, reverse);
digitalWrite(in2PinMotorAF, !reverse);
delay(3000);
//go back -> working
analogWrite(enablePinMotorAF, 230); //max speed
digitalWrite(in1PinMotorAF, !reverse);
digitalWrite(in2PinMotorAF, reverse);
delay(3000);
//go right -> working
analogWrite(enablePinMotorLR, 230); //max speed
digitalWrite(in1PinMotorLR, !reverse);
digitalWrite(in2PinMotorLR, reverse);
delay(3000);
//go left -> working
analogWrite(enablePinMotorLR, 230); //max speed
digitalWrite(in1PinMotorLR, reverse);
digitalWrite(in2PinMotorLR, !reverse);
delay(3000);
}
Here is the wiring too:
The green and orange wires are for a Bluetooth module.
Do you have any idea how can I solve this problem and to make it work?
Thank you.