Difference between revisions of "Adafruit Motor Shield V2"

From Interaction Station Wiki
Jump to navigation Jump to search
Line 25: Line 25:
 
Connect the positive side of the power terminal to the positive side of the barrel jack.
 
Connect the positive side of the power terminal to the positive side of the barrel jack.
 
Connect the negative side of the power terminal to the negative side of the barrel jack.
 
Connect the negative side of the power terminal to the negative side of the barrel jack.
 +
 +
In the picture two motors are attached, but in our example we'll only use 1.
  
 
<b>Programming</b>
 
<b>Programming</b>
 +
 +
To program the shield, we need to upload a code to the Arduino UNO using Arduino IDE. Luckily we don't need to write the whole code ourselves, but we can start with examples that are in the the Adafruit Motor Shield V2 library.
 +
 +
Do you have Arduino IDE? If not, go to https://www.arduino.cc/en/software and download the latest version.
 +
 +
Open Arduino IDE and go to Sketch -> Include Library -> Manage Libraries...
 +
 +
[[File:Adafruit products managelib.png|400px]]
 +
 +
Now look for Adafruit Motor Shield in the search bar and install Adafruit Motor Shield V2 Library by Adafruit.
 +
 +
[[File:Adafruit products motor.png|400px]]
  
 
==Servo Motors==
 
==Servo Motors==

Revision as of 08:56, 18 July 2024

Adafruit Motor Shield V2

Adafruit Motor Shield V2 allows you to easily control the speed and direction of 4 DC motors, the position of 2 servo motors and the steps of 2 stepper motors. The shield is made for the Arduino UNO and can be easily installed on it.

The shield uses I2C to operate, which is a communication protocol between the Arduino and the shield. This means that all the other non-I2C pins (so everything other than A4 and A5) can be uses to read sensor data or control other things. I2C also means that the shield is stackable. You can use up to 32 shields at the same time, meaning that you can use up to 64 steppers or 128 DC motors!

!The Adafruit Motor Shield can handle 4 DC motors with each using a maximum of 1,3A, so it's made for small to medium sized motors!

DC Motors

One Adafruit Motor Shield can be used to control the speed and direction of 4 DC motors at the same time. Here I'll give you an example of how to run 1 motor.

Wiring

Now let's wire a motor to the shield.

Adafruit products dcmotortest.jpg

Connect the wires of your motor to one of the terminals. In our case you'll use the M1 terminal.

Now connect your power supply to the power terminals of the shield. You'll want to connect a barrel jack to the power terminal to attach an appropriate external power source to the Shield. The Shield will not function without an external power source!

Adafruit products MetroM0 MotorShield bb.png

Connect the positive side of the power terminal to the positive side of the barrel jack. Connect the negative side of the power terminal to the negative side of the barrel jack.

In the picture two motors are attached, but in our example we'll only use 1.

Programming

To program the shield, we need to upload a code to the Arduino UNO using Arduino IDE. Luckily we don't need to write the whole code ourselves, but we can start with examples that are in the the Adafruit Motor Shield V2 library.

Do you have Arduino IDE? If not, go to https://www.arduino.cc/en/software and download the latest version.

Open Arduino IDE and go to Sketch -> Include Library -> Manage Libraries...

Adafruit products managelib.png

Now look for Adafruit Motor Shield in the search bar and install Adafruit Motor Shield V2 Library by Adafruit.

Adafruit products motor.png

Servo Motors

Wiring

Programming

Stepper Motors

Wiring

Programming