8
6.2
How to drive 2 DC motors
Note:
The first thing to notice however, is that you need an external power source for your DC motors. The 5v pin
on the Arduino cannot provide enough power to drive 2 motors, you may damage your Arduino if you do
so.
And then program your Arduino as below:
#include <Wire.h>
.......
.......
<
Driver functions
>
.......
.......
void
setup
()
{
Wire
.
begin
();
// join i2c bus (address optional for master)
delayMicroseconds
(
10000
);
//wait for motor driver to initialization
}
void
loop
()
{
while
(
1
)
{
MotorSpeedSetAB
(
100
,
20
);
delay
(
10
);
//this delay needed
MotorDirectionSet
(
0b1010
);
//0b1010 Rotating in the positive direction
Содержание Grove I2C Motor Driver
Страница 2: ...2 Document Revision History Revision Date Author Description 1 0 Sep 21 2015 Victor He Create file ...
Страница 9: ...6 5 Application ideas Robots Homebuilt RC cars Case fans High power LED illumination ...
Страница 20: ...17 10 Support If you have questions or other better design ideas you can go to our forum or wish to discuss ...