This is my first post so please bear with me...
I'm modding an RC car using an H-bridge on my Arduino Uno.it has two motors. The rear for propulsion and the front is for steering. the rear wheels work perfectly moving forward and backward as designed (Thanks to your tutorial section for all of your help). The front steering is where my problem comes in. They turn right when appropriate, but I get no response when asked to turn left. The steering motor has only two wires and appears to work on a spring basis. When you give a positive current to one side they turn right, when you reverse the current they turn left. When there is no current they spring to the center position. I tested it with a regular 3v DC batter and they turn perfectly. However when connected through the H Bridge they do not turn left, but do turn right perfectly. I check the current coming out of the leads from the H Bridge and as designed provide a positive current when asked and a negative current when asked. What am I doing wrong? Why don't they turn left?
I have the Hbridge connected to an external power supply of 9.6 volts. So i can get the car to go forward, reverse, right, but not left.... What am I missing here?
Thank you in advance for all of your help.
Sincerely,
Carlos
Here is my code:
/
/R.E.M.O. Sketch v 1.2
int moveMotor;
const int motor1Pin = 3; // H-Bridge Leg 1
const int motor2Pin = 4; // H-Bridge leg 2
const int enablePin = 9; //H-Bridge enable pin
const int turn1Pin = 5; // H-Bridge leg 4A
const int turn2Pin = 6; // H-Bridge leg 3A
void setup() {
pinMode(motor1Pin, OUTPUT); //Power to wheels back
pinMode(motor2Pin, OUTPUT); //Power to wheels back2
pinMode(enablePin, OUTPUT);
pinMode(turn1Pin, OUTPUT); //Turning wheels
pinMode(turn2Pin, OUTPUT); //Turning wheels2
digitalWrite(enablePin, HIGH);
Serial.begin(115200);
Serial.println("Remote Exploratory Mobile Unit 1.2");
Serial.println("by CHR1112");
Serial.println();
}
void loop() {
if (Serial.available() > 0){
moveMotor = Serial.read(); // take signal from keyboard.
//ASCII codes: "f" = 102, "b"=98, "l"=108, "r"=114
if (moveMotor == 102) {
//forward motion by the letter 'f'
analogWrite(motor1Pin, 120);
digitalWrite(motor2Pin, HIGH);
}
else if (moveMotor == 98) {
//backward motion by the letter 'b'
analogWrite(motor1Pin, 120);
digitalWrite(motor2Pin, LOW);
}
else if (moveMotor == 114) {
// right turn by the letter 'r'
analogWrite(turn1Pin, 90);
analogWrite(motor1Pin, 120);
digitalWrite(turn2Pin, HIGH);
digitalWrite(motor2Pin, HIGH);
}
else if (moveMotor == 108) {
//left turn by the letter 'l'
analogWrite(turn1Pin, 90);
analogWrite(motor1Pin, 120);
digitalWrite(turn2Pin, LOW);
digitalWrite(motor2Pin, HIGH);
}
else {
//stop everything.
digitalWrite (motor1Pin, LOW);
digitalWrite (motor2Pin, LOW);
digitalWrite (turn1Pin, LOW);
digitalWrite (turn2Pin, LOW);
}
}
}
Moderator edit: CODE TAGS