D. programming your arduino – Pololu Dual MC33926 User Manual
Page 13
![background image](/manuals/570387/13/background.png)
Motor with one 0.1 uF capacitor
soldered across its terminals.
Motor with two 0.1 uF capacitors
soldered from its terminals to its
case.
consider taking the following steps to decrease the impact of motor-induced electrical noise on the rest of your
system:
1. Solder a
across the terminals of your motors, or solder one
capacitor from each terminal to the motor case (see the pictures to the
right). For the greatest noise suppression, you can use three capacitors
per motor (one across the terminals and one from each terminal to the
case).
2. Make your motor leads as thick and as short as possible, and twist
them around each other. It is also beneficial to do this with your power
supply leads.
3. Route your motor and power leads away from your logic
connections if possible.
4. Place decoupling capacitors (also known as “bypass capacitors”)
across power and ground near any electronics you want to isolate from
noise. These can typically range from 10 uF to a few hundred uF.
3.d. Programming Your Arduino
Our Arduino library for the dual MC33926 motor driver shield makes it easy to get started writing your Arduino
sketches. A link to download the library, installation instructions, and the library command reference can be found
on the
try out the example sketch by selecting
File > Examples > DualMC33926MotorShield > Demo
from the Arduino IDE, or by copying the following code into a new sketch:
#include "DualMC33926MotorShield.h"
DualMC33926MotorShield md;
void stopIfFault()
{
if (md.getFault())
{
Serial.println("fault");
while(1);
}
}
void setup()
{
Serial.begin(115200);
Serial.println("Dual MC33926 Motor Shield");
md.init();
}
void loop()
{
for (int i = 0; i <= 400; i++)
{
md.setM1Speed(i);
stopIfFault();
if (abs(i)%200 == 100)
{
Serial.print("M1 current: ");
Serial.println(md.getM1CurrentMilliamps());
Pololu Dual MC33926 Motor Driver Shield User's Guide
© 2001–2013 Pololu Corporation
3. Getting Started with an Arduino
Page 13 of 24