protected Servo servo;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
servo = new Servo(Device.Pins.D02, NamedServoConfigs.SG90);
return Task.CompletedTask;
}
public async override Task Run()
{
await servo.RotateTo(new Angle(0, AU.Degrees));
while (true)
{
for (int i = 0; i <= servo.Config.MaximumAngle.Degrees; i++)
{
await servo.RotateTo(new Angle(i, AU.Degrees));
Resolver.Log.Info($"Rotating to {i}");
}
await Task.Delay(2000);
for (int i = 180; i >= servo.Config.MinimumAngle.Degrees; i--)
{
await servo.RotateTo(new Angle(i, AU.Degrees));
Resolver.Log.Info($"Rotating to {i}");
}
await Task.Delay(2000);
}
}