11
The connection between 24BYJ48 Stepper Motor and I2C Motor Driver is shown as blow:
Download the
Grove-I2C motor driver V1.3 demo code
, and open the
StepperControlMode2.ino
:
#include <Wire.h>
#define MotorSpeedSet 0x82
#define PWMFrequenceSet 0x84
#define DirectionSet 0xaa
#define MotorSetA 0xa1
#define MotorSetB 0xa5
#define Nothing 0x01
#define EnableStepper 0x1a
#define UnenableStepper 0x1b
#define Stepernu 0x1c
#define I2CMotorDriverAdd 0x0f
// Set the address of the I2CMotorDriver
// set the steps you want, if 255, the stepper will rotate continuously;
void
SteperStepset
(
unsigned
char
stepnu
)
{
Wire
.
beginTransmission
(
I2CMotorDriverAdd
);
// transmit to device I2CMotorDriverAdd
Wire
.
write
(
Stepernu
);
// Send the stepernu command
Wire
.
write
(
stepnu
);
// send the steps
Wire
.
write
(
Nothing
);
// send nothing
Wire
.
endTransmission
();
// stop transmitting
}
.......
.......
.......
.......
void
stepperrun
()
{
Serial
.
println
(
"sent command to + direction, very fast"
);
SteperStepset
(
255
);
StepperMotorEnable
(
1
,
1
);
// ennable the i2c motor driver a stepper.
delay
(
5000
);
Serial
.
println
(
"sent command to - direction, slow"
);
SteperStepset
(
255
);
StepperMotorEnable
(
0
,
20
);
Содержание 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 ...