How to make a motor go backwards?

Hello, currently I have a motor going forwards with the script below and using a mosfet transistor. My question is, is their a way to make the motor go backwards with the arduino language, and is their more hardware that I need to implement to make it go backwards?

#define MOTOR 9

void setup()
  pinMode(MOTOR, OUTPUT);

void loop()
  digitalWrite(MOTOR, HIGH);

Thanks a bunch, Flashuni :)

More hardware is required. To reverse a DC motor on must reverse the direction of current going through the motor. This can be done either with a DPDT relay or a H-drive motor driver circuit. This would require another Arduino output pin to be used to control the direction for the motor and of course the proper software statements to control the pin.


Or you could use a stepper motor if you want much more precise movement.

iv done quite a few little projects with stepper motor, they are really easy to use and can be found in junk driskdrives, printers, scanners, faxes and so on.

You'll need 3 more transistors as mentioned above by lefty.

Have a read on this:

I found it useful to buy an h-bridge.
The one I got could run 2 motors, forward or backward, independently.
This made it useful for robots, like ones using the arduino rover chassis.