Meadow.Foundation.Motors.Stepper.A4988
| A4988 | |
|---|---|
| Status | |
| Source code | GitHub |
| Datasheet(s) | GitHub |
| NuGet package |
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:
| A4988 | Meadow Pin |
|---|---|
| GND | GND |
| VCC | 5V |
| STEP | D01 |
| DIRECTION | D00 |
| M1 | D04 |
| M2 | D03 |
| M3 | D02 |
It should look like the following diagram:
