Step 4: One Motor

Picture of One Motor
To control a motor using the Arduino Motor Shield, first plug the motor's positive (red) wire into Channel A's + terminal on the motor shield, and the motor's ground (black) wire into Channel A's - terminal on the shield.

An external power supply is not always necessary, but it drastically improves the motor's performance. It is recommended that you always use one.

To connect your external power supply, connect the positive (red) wire from the power supply to the "Vin" terminal, and the ground (black) wire to the "GND" terminal.

Finally, upload the code to control the Motor Shield to the Arduino.

Here is the code for controlling one motor:

critopadolf2 years ago
I am trying to control two motors, a servo, and a Ping sensor. am i able to connect the servo to one of the orange or white plugs to control it? or would i have to connect it normally to the arduino's pins
chris9112 years ago
How do i write the code to make a momentary switch, start the motor. Without having to hold down the switch?
dman32 years ago
i uploaded this code but the wheels aren't turning...
any help?
fbasmajian2 years ago
you have an error with the serial port. you need to tools-serial port-and then change the serial port
THE STIG373 years ago
i am using the code given with dougstrickland's correction and i try to upload it and the motor isnt turning and i get an orange line of code at the bottom that says
avrdude: stk500_getsync(): not in sync: resp=0x00
Thanks for putting this together, there's little out there currently on this shield.

You have a problem with a line in your code:

analogWrite(3, 1023); //Spins the motor on Channel A at full speed

According to the Arduino Reference, analogWrites are 0-255 not 0-1023.

here: http://bit.ly/Hw6GyX

When I changed this to 255, and the half-speed value to 128, everything worked.