12
delay
(
5000
);
Serial
.
println
(
"sent command to - direction, fast"
);
StepperMotorEnable
(
0
,
2
);
// ennable the i2c motor driver a stepper.
delay
(
5000
);
Serial
.
println
(
"sent command to + direction,100 steps, fast"
);
SteperStepset
(
100
);
StepperMotorEnable
(
1
,
5
);
delay
(
3000
);
Serial
.
println
(
"sent command to shut down the stepper"
);
StepperMotorUnenable
();
delay
(
1000
);
Serial
.
println
(
"sent command to - direction, slow, and 10 steps then stop"
);
SteperStepset
(
10
);
StepperMotorEnable
(
0
,
40
);
delay
(
5000
);
Serial
.
println
(
"sent command to shut down the stepper"
);
StepperMotorUnenable
();
delay
(
5000
);
}
void
setup
()
{
Wire
.
begin
();
// join i2c bus (address optional for master)
delayMicroseconds
(
10000
);
Serial
.
begin
(
9600
);
Serial
.
println
(
"setup begin"
);
stepperrun
();
}
void
loop
()
{
}
In this demo code, Arduino sends stepper-control command to I2C motor driver via I2C bus, with
SteperStepset() to set the step number, and StepperMotorEnable() to set the direction and speed. Please
for the details.
Note that if you have I2C motor driver V1.2 and want to use the off-line Stepper control methods, you will
need to upgrade your firmware in your V1.2 motor driver with a AVRISP and upload the .hex file to your
I2C motor driver. Please download the .hex file and source code and related tips in the