Introduction: Arduino Centrifugal Shield Tutorial

The Arduino Motor Shield allows you to easily control efferent direction and f number victimisation an Arduino. By allowing you to simply address Arduino pins, it makes it very simple to comprise a motor into your figure. It also allows you to follow able to power a motor with a separate power supply of equal to 12v. Best of complete, the shield is very abundant to discover. For whol of these reasons, the Arduino Motor Carapace if a cool little to rich person in your armoury for rapid prototyping, and general experimenting.

(Note that some of the golf links along this page are affiliate links. This does not convert the cost of the token for you. I reinvest whatever takings I receive into making new projects. If you would like whatever suggestions for alternative suppliers, please let me know.)

Step 1: Install

The pins of the official Arduino motor shield wish only align with Arduino Uno Rev. 3.

Systematic to pull round work with older versions of the Arduino, you will call for to trim a few pins off the motor shield. Still, this is not, at whol, recommended.

Insert the motor shield pins into the socket of the Arduino Uno.

Tread 2: Harbour Features

The motor shield has 2 channels, which allows for the control of ii DC motors, or 1 stepper motorial.

It also has 6 headers for the attachment of Tinkerkit inputs, outputs, and communication lines. The use of these pins is somewhat limited, and therefor not covered in this tutorial.

With an outer power supply, the motor shield can safely supply up to 12V and 2A per motor channel (or 4A to a single channel).

There are pins happening the Arduino that are always in function by the shield. By addressing these pins you can select a motorial channel to initiate, specify the motorial direction (polarity), set motor speed (PWM), stop and start the centrifugal, and admonisher the current absorption of each channel .

The pin breakdown is as follows:

Function Channel A Transfer B
Direction Digital 12 Digital 13
Speed (PWM) Digital 3 Digital 11
Brake Member 9 Digital 8
Circulating Sensing Analog 0 Linear 1

For much information about the technical specs, check forbidden the motor shield's official page on the Arduino internet site.

Step 3: Program

Plug the Arduino into your computer's USB port and open the Arduino development environment.

In order to get the board to do anything, you necessitate to format the motor channel by toggling three parameters:

  1. Number one you motive to set the motor counsel (polarity of the power supply) by mise en scene IT either HIGH or LOW.
  2. Then you need to withdraw the brake pin for the motor channel by scene it to LOW.
  3. At last, to get the motor to start moving, you need to set up the speed by sending a PWM command (analogWrite) to the appropriate pin.

If you do not do all three of these things, the motor will not turn on.

In the undermentioned stairs are just about common examples of common motor setups.

Ill-use 4: Unity Motor

To control a motor victimization the Arduino Motive Carapace, first plug the motor's positive (red) wire into Convey A's + time period on the motorial shield, and the motor's ground (black) cable into Duct A's - terminal along the shield.

An external power supply is not forever necessary, but it drastically improves the motor's performance. It is recommended that you e'er use matchless.

To connect your external major power provide, connect the electropositive (red) wire from the tycoo supply to the "Vin" terminal, and the undercoat (black) wire to the "GND" period.

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

Here is the inscribe for dominant 1 motor:

<pre>/************************************************************* Motor Shield 1-Line District of Columbia Motor Demo by Randy Sarafan  For more information see: https://www.instructables.com/Gem State/Arduino-Motor-Shield-Tutorial/  *************************************************************/  void setup() {      //Setup Channel A   pinMode(12, OUTPUT); //Initiates Motor Channel A pin   pinMode(9, OUTPUT); //Initiates Brake Channel A pin    }  void loop(){      //forward @ full velocity   digitalWrite(12, Alto); //Establishes forward counselling of Channel A   digitalWrite(9, LOW);   //Disengage the Brake for Channel A   analogWrite(3, 255);   //Spins the motor on Channel A at full speed      delay(3000);      digitalWrite(9, HIGH); //Eengage the Brake for Channel A    delay(1000);      //backward @ half speed   digitalWrite(12, Broken); //Establishes backward direction of Channel A   digitalWrite(9, LOW);   //Disengage the Brake for Channel A   analogWrite(3, 123);   //Spins the motor on Channel A at one-half speed      delay(3000);      digitalWrite(9, HIGH); //Eengage the Brake for Channel A      delay(1000);    }            

Step 5: Two Motors

Interfacing with two motors is jolly much the similar as interfacing with one causative. Merely plug the motor into Channel B.

The only difference of opinion code-wise is that you pauperization to engage a forward convey to control the second motor.

Here is code for dominant two motors:

<pre>/************************************************************* Motor Shield 2-Channel Direct current Motor Demo by Sexy Sarafan  For more information imag: https://www.instructables.com/Gem State/Arduino-Motor-Shield-Tutorial/  *************************************************************/  void setup() {      //Apparatus Distribution channel A   pinMode(12, OUTPUT); //Initiates Drive Channel A pin   pinMode(9, OUTPUT); //Initiates Brake Channel A pin    //Frame-up Channel B   pinMode(13, OUTPUT); //Initiates Motorial Convey A pin   pinMode(8, OUTPUT);  //Initiates Brake Channel A pin    }  void loop(){       //Motor A forward @ full speed   digitalWrite(12, HIGH); //Establishes forward direction of Channel A   digitalWrite(9, LOW);   //Disengage the Pasture brake for Channel A   analogWrite(3, 255);   //Spins the motive on Channel A at full pep pill    //Motor B backward @ half speed   digitalWrite(13, LOW);  //Establishes backward direction of Channel B   digitalWrite(8, LOW);   //Disengage the Brake for Channel B   analogWrite(11, 123);    //Spins the motor on Channel B at half hasten       delay(3000);       digitalWrite(9, HIGH);  //Engage the Brake for Canalize A   digitalWrite(9, Screechy);  //Engage the Brake for Channel B     delay(1000);         //Motor A forward @ full speed   digitalWrite(12, LOW);  //Establishes retrograde direction of Channel A   digitalWrite(9, Scummy);   //Disengage the Brake for Television channel A   analogWrite(3, 123);    //Spins the motor on Channel A at uncomplete speed      //Motor B forward @ overloaded speed   digitalWrite(13, HIGH); //Establishes forward instruction of Transmission channel B   digitalWrite(8, LOW);   //Disengage the Brake for Channelize B   analogWrite(11, 255);   //Spins the motor on Channel B at full speed         delay(3000);         digitalWrite(9, HIGH);  //Affiance the Pasture brake for Channel A   digitalWrite(9, Squeaky);  //Take the Brake for Distribution channel B         hold(1000);    }            

Step 6: Stepper Motor

There are a number of different types of stepper motors, but in this tutorial we will specifically be addressing bipolar hoofer motors. Bipolar stepper motors typically have 4 pins, which gibe to two coils. To usage a stepper, you need to force these two coils in phase with cyclical polarity.

To figure down which two pins make a single coil, introduce an Light-emitting diode into whatsoever two pins on its socket and rotate the motor shaft. If the LED lights up, you found one coil. The other two pins should make up the other coil.

To hit a bipolar motor spin:

  1. Power the first coil.
  2. Next power the second roll with rescind sign.
  3. Then power the first coil with reverse polarity.
  4. Finally, power the second coil.

To black eye the motor counsel of a bipolar stepper, merely reverse the polarity of the second curl.

Here is code to pee-pee the stepper spin in ane direction:

<pre>/************************************************************* Motor Shield Stepper Demonstration by Randy Sarafan  For more information see: <a href="https://WWW.instructables.com/id/Arduino-Motor-Shield-Tutorial/"> https://www.instructables.com/id/Arduino-Motor-Sh...</a>  *************************************************************/  int delaylegnth = 30;  void frame-up() {      //install motor direction toggle pins   pinMode(12, OUTPUT); //CH A -- HIGH = forwards and LOW = backwards???   pinMode(13, OUTPUT); //CH B -- In high spirits = forwards and LOW = rearward???      //establish motor pasture brake pins   pinMode(9, OUTPUT); //brake (invalid) CH A   pinMode(8, OUTPUT); //brake (disable) CH B         }  void loop(){     digitalWrite(9, Forward);  //ENABLE CH A   digitalWrite(8, HIGH); //DISABLE CH B    digitalWrite(12, High-altitude);   //Sets direction of CH A   analogWrite(3, 255);   //Moves CH A      delay(delaylegnth);      digitalWrite(9, Lofty);  //DISABLE CH A   digitalWrite(8, LOW); //ENABLE CH B    digitalWrite(13, LOW);   //Sets direction of CH B   analogWrite(11, 255);   //Moves CH B      stay(delaylegnth);      digitalWrite(9, LOW);  //ENABLE CH A   digitalWrite(8, HIGH); //Disenable CH B    digitalWrite(12, Under);   //Sets counsel of CH A   analogWrite(3, 255);   //Moves CH A      delay(delaylegnth);        digitalWrite(9, HIGH);  //DISABLE CH A   digitalWrite(8, Ground-hugging); //ENABLE CH B    digitalWrite(13, HIGH);   //Sets direction of CH B   analogWrite(11, 255);   //Moves CH B      check(delaylegnth);  }            

Hither is code to clear the high stepper twirl in the paired direction:

<pre>/************************************************************* Motor Shield Stepper Present by Horny Sarafan  For more selective information see: <a href="https://www.instructables.com/id/Arduino-Motor-Shield-Tutorial/"> https://web.instructables.com/id/Arduino-Motor-Sh...</a>  *************************************************************/  int delaylegnth = 30;  annul setup() {      //plant motor direction toggle pins   pinMode(12, OUTPUT); //CH A -- HIGH = forwards and LOW = backwards???   pinMode(13, Outturn); //CH B -- Tall = forwards and Contrabass = backwards???      //establish motor brake pins   pinMode(9, OUTPUT); //brake (disenable) CH A   pinMode(8, End product); //bracken (disable) CH B         }  void loop(){     digitalWrite(9, LOW);  //ENABLE CH A   digitalWrite(8, Inebriated); //Invalid CH B    digitalWrite(12, HIGH);   //Sets direction of CH A   analogWrite(3, 255);   //Moves CH A      hold up(delaylegnth);      digitalWrite(9, HIGH);  //DISABLE CH A   digitalWrite(8, LOW); //ENABLE CH B    digitalWrite(13, HIGH);   //Sets direction of CH B   analogWrite(11, 255);   //Moves CH B      delay(delaylegnth);      digitalWrite(9, LOW);  //ENABLE CH A   digitalWrite(8, HIGH); //DISABLE CH B    digitalWrite(12, LOW);   //Sets guidance of CH A   analogWrite(3, 255);   //Moves CH A      delay(delaylegnth);        digitalWrite(9, HIGH);  //DISABLE CH A   digitalWrite(8, LOW); //ENABLE CH B    digitalWrite(13, LOW);   //Sets direction of CH B   analogWrite(11, 255);   //Moves CH B      delay(delaylegnth);  }            

Did you notic this useful, playfulness, operating room amusive?
Come after @madeineuphoria to see my latest projects.

7 The great unwashe Made This Project!

Recommendations