Controlling DC Motors with A-STAR 32U4 LV Robot Controller(SMT Componentes Only)

I am having some doubts on how to control DC motors with this particular board.
Let’s say I want to get 2 motors moving Forward:
#include <AStar32U4.h> AStar32U4Motors motors; void setup(){ } void loop{ motors.setSpeeds(400, 400); }

Would this work?
If possible, I would also like to know what is the difference between motors.flipM1/2(true); or simply motors.setM1/2Speed(-speed)



I do not see anything obviously wrong with your code. It looks like it sets the motors to maximum speed in the forward direction (motor driver outputs corresponding to current flowing from output A to B). So, if that behavior is what you want, it sounds like it will work for you.

As for the difference in those functions, calling flipM1() or flipM2() with an argument of true flips the meaning of “forward” and “reverse”, which means that any subsequent calls to setM1Speed(), setM2Speed(), or setSpeeds() will take the new meaning of “forward” and “reverse” into account. Whereas, calling setM1Speed(), setM2Speed(), or setSpeeds() with a negative speed value simply commands the motor to rotate in reverse (and the meaning of “forward” and “reverse” does not change). One example of how flipM1() or flipM2() can be useful is when code (like our example sketch, Motors.ino) is already written and the motors are wired in a way that the forward direction does not make sense for the system. Instead of rewiring the motors, you can use the flipM1() or flipM2() commands to accomplish the same thing as rewiring the motors, except in code.

You can learn more about how all of the functions in the A-Star library work by reading about them in the AStar32U4 library documentation.


1 Like