Go_function_by_lit

(https://git@github.com:PhoenixIIexe/Go.git)

Please explain why you posted that link to github.com

If a reasonable explanation is not received within 24 hours this topic will be deleted and you will be banned

So... a library that does nothing but:

void go (int m1, int m2)
{
  digitalWrite(4, m1 >= 0 ? 1 : 0);
  analogWrite(5, m1 < 255 ? abs(m1) : 255);
  digitalWrite(7, m2 >= 0 ? 1 : 0);
  analogWrite(6, m2 < 255 ? abs(m2) : 255);
}

Looks like it's turning two signed motor speeds into separate PWM and Direction signals. Looks OK until m1 or m2 is below -255.

You could use the constrain function to cover both < -255 and >255:
analogWrite(6, abs(constrain(m2, -255, 255)));

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.