One motor is wired incorrectly (polarity reversed)

While installing my pi3+ robot, I wired the right motor with the polarity reversed, so the right motor now rotates in the wrong direction. Not wanting to re-solder the connection, I was wondering about the easiest way to fix this in the programming. Would it be something I can change in a library, or something I need to do in each arduino sketch?


Hello, Steve.

Either of the solutions you mentioned (editing the library or handling it in each sketch) would work. Our library includes flipLeftMotor() and flipRightMotor() commands that you can use in each sketch to correct for this kind of scenario. You can see how we use these in the LineFollowerPID code for the hyper edition of the 3p+ robot (since they have a different number of gears in the gear train and spin the opposite direction as the others).

If you want to modify your library so you don’t have to worry about doing that in every sketch, the easiest way would probably be to edit Pololu3piPlus32U4Motors.cpp to just change the default state of the corresponding flipLeft or flipRight variable to true instead of false.


Thanks Brandon,

I found the flip motor commands, and letting me know about the library is great. I’ve decided it’s best to use the flip commands so I can update the library in future without worrying about retrofitting changes.

I really like the features built in to the 3pi+, and great engineering for the chassis overall.

Thanks for your help and have a great day.


1 Like

As you dont want to change the polarity of the motors.Its better you change the code a little bit in arduino IDE. If you are using l298n motor driver then you can simply change the (High/1) statement to (Low/0)