Skip to main content

Meadow.Foundation.Motors.Stepper.A4988

A4988
StatusStatus badge: working
Source codeGitHub
Datasheet(s)GitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Motors.Stepper.A4988

Code Example

private A4988 a4988;

public override Task Initialize()
{
a4988 = new A4988(
step: Device.Pins.D01,
direction: Device.Pins.D00,
ms1Pin: Device.Pins.D04,
ms2Pin: Device.Pins.D03,
ms3Pin: Device.Pins.D02);

return base.Initialize();
}

public override Task Run()
{
var stepDivisors = (StepDivisor[])Enum.GetValues(typeof(StepDivisor));
while (true)
{
foreach (var step in stepDivisors)
{
for (var d = 2; d < 5; d++)
{
Resolver.Log.Info($"180 degrees..Speed divisor = {d}..1/{(int)step} Steps..{a4988.Direction}...");
a4988.RotationSpeedDivisor = d;
a4988.StepDivisor = step;
a4988.Rotate(180);

Thread.Sleep(500);
}
}
a4988.Direction = (a4988.Direction == RotationDirection.Clockwise) ? RotationDirection.CounterClockwise : RotationDirection.Clockwise;
}
}

Sample project(s) available on GitHub

Wiring Example

To wire a A4988 to your Meadow board, connect the following:

A4988Meadow Pin
GNDGND
VCC5V
STEPD01
DIRECTIOND00
M1D04
M2D03
M3D02

It should look like the following diagram: