Uhhh hii, I'm new to robotics and a highschool student
So I have a problem about the delay of my RC car, because if i push the left and right buttons it has a delay for like 2-4 secs before it moves (let's say its like lagging dunno if its the right term to say, I suck at english). Also my forward and backward isn't responding and i guess its because of the code or what. Need help and maybe could get some tips :>
here is the Code:
char t;
void setup() {
pinMode(12,OUTPUT); //left motors forward
pinMode(11,OUTPUT); //left motors reverse
pinMode(10,OUTPUT); //right motors forward
pinMode(9,OUTPUT); //right motors reverse
Serial.begin(9600);
}
void loop() {
if(Serial.available()){
t = Serial.read();
Serial.println(t);
}
if(t == 'F'){ //move forward(all motors rotate in forward direction)
digitalWrite(12,HIGH);
digitalWrite(10,HIGH);
}
else if(t == 'B'){ //move reverse (all motors rotate in reverse direction)
digitalWrite(11,HIGH);
digitalWrite(9,HIGH);
}
else if(t == 'L'){ //turn right (left side motors rotate in forward direction, right side motors doesn't rotate)
digitalWrite(11,HIGH);
}
else if(t == 'R'){ //turn left (right side motors rotate in forward direction, left side motors doesn't rotate)
digitalWrite(12,HIGH);
}
else if(t == 'S'){ //STOP (all motors stop)
digitalWrite(12,LOW);
digitalWrite(11,LOW);
digitalWrite(10,LOW);
digitalWrite(9,LOW);
}
delay(100);
}
Since you added a 100 ms delay in your code, I don´t know how to explain a 2 sec. delay based on the info provided. However, I can tell you that a DC motor direction is controlled setting one wire HIGH while the other wire is LOW. You´re just setting them HIGH.
I mean, when you want both motors forward it´s not enough to set:
Hello, so i tried using another application and the delay is gone, however the problem is that if i push the right button it powers all of the right dc motors; left button powers all right dc motors and the forward button and backward buttons doesn't do any but it make the moving dc motors to stop. Also did the thing you told to add a LOW or HIGH
also here is my schematic diagram (still not connecting my servos cuz I'm focusing on the dc motors first but maybe needing some help after if i encounter any on servos)
ps. sorry if the diagram very messy i dont know how to make a proper one xD
Hello, I fixed my problem with the movements and its working fine now, i just fixed the code since the pins i put in the code were errors thus, the movement was a mess
It was supposed to be
LEFT MOTOR
Input 1 = pin9 (FORWARD)
Input 2 = pin11 (BACKWARD)
RIGHT MOTOR
Input 3= pin10 (FORWARD)
Input 4 = pin12 (BACKWARD)
but i might need help later on about servos if i encounter one