private IStepperMotor stepper;
public override Task Initialize()
{
stepper = new Em542s(
Device.Pins.D15.CreateDigitalOutputPort(),
Device.Pins.D14.CreateDigitalOutputPort(),
inverseLogic: true);
return base.Initialize();
}
public override Task Run()
{
var direction = RotationDirection.Clockwise;
var rate = new Meadow.Units.Frequency(200, Meadow.Units.Frequency.UnitType.Kilohertz);
while (true)
{
Resolver.Log.Info($"{direction}");
stepper.Rotate(360f, direction, rate);
Thread.Sleep(1000);
direction = direction switch
{
RotationDirection.CounterClockwise => RotationDirection.Clockwise,
_ => RotationDirection.CounterClockwise
};
}
}