Hey guys,
I am a novice in electronics and coding, so my question could be silly, thank you for understanding first,
I have a code which has if statements. Code runs two motors in one direction via two motor drivers bts7960B. When I run the code, in each condition, only one motor driver works, so only one motor works. I hav investihgate the problem, then i found a syntax mistake in If statement which can you find in below code.
what i am thinking is, how the code run only one motor, while there is a syntax error in both if statements? Normally, since if statement are faulty, no motor should run, instead of running only right motor right?
if (aoutput > pos); {
rmotor();
}
if (aoutput < pos); {
lmotor();
}
void rmotor() {
analogWrite(RPWM1,conout);
digitalWrite(LPWM1,LOW);
analogWrite(RPWM2,LOW);
digitalWrite(LPWM2,LOW);
delay (25);
}
void lmotor() {
analogWrite(RPWM1,LOW);
digitalWrite(LPWM1,LOW);
analogWrite(RPWM2,conout);
digitalWrite(LPWM2,LOW);
delay (25);
}
I did not understand why only one motor worked. I have prepared both conditions (i have an lcd which shows aoutput and pos values) and measured voltages on both drivers, however only the right motor have working.
Very strange situation for me and try to figure out. I will appreciate, IF
anybody can help me.
Regards.