Skip to main content

Meadow.Foundation.Motors;.BidirectionalDcMotor

BidirectionalDcMotor
StatusStatus badge: working
Source codeGitHub
NuGet packageNuGet Gallery for Meadow.Foundation

Code Example

private BidirectionalDcMotor motor;

public override Task Initialize()
{
Resolver.Log.Info("Initializing...");

IDigitalOutputPort motorA;
IDigitalOutputPort motorB;

motorA = Device.Pins.D00.CreateDigitalOutputPort(false);
motorB = Device.Pins.D01.CreateDigitalOutputPort(false);

motor = new BidirectionalDcMotor(motorA, motorB);

return Task.CompletedTask;
}

public override async Task Run()
{
Resolver.Log.Info("Test Motor...");

while (true)
{
// Motor clockwise
motor.StartClockwise();
await Task.Delay(1000);

// Motor Stop
motor.Stop();
await Task.Delay(500);

// Motor counter clockwise
motor.StartCounterClockwise();
await Task.Delay(1000);

// Motor Stop
motor.Stop();
await Task.Delay(500);
}
}

Sample project(s) available on GitHub