protected HBridgeMotor motor1;
public override Task Initialize()
{
Resolver.Log.Info("Initializing...");
motor1 = new HBridgeMotor
(
a1Port: Device.CreatePwmPort(Device.Pins.D07, new Frequency(100, Frequency.UnitType.Hertz)),
a2Port: Device.CreatePwmPort(Device.Pins.D08, new Frequency(100, Frequency.UnitType.Hertz)),
enablePort: Device.CreateDigitalOutputPort(Device.Pins.D09)
);
return Task.CompletedTask;
}
public override async Task Run()
{
Resolver.Log.Info("TestMotor...");
while (true)
{
motor1.Power = 1f;
await Task.Delay(1000);
motor1.Power = 0f;
await Task.Delay(500);
motor1.Power = -1f;
await Task.Delay(1000);
}
}