Know the rotation/polarity of a DC motor - Beginners

What motor driver are you using?

If a transistor, you will need to switch the motor's power leads.

If an H-bridge, you can reverse in software.

Post your test code. Read the forum guidelines to see how to properly post code and some good information on making a good post.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.