Meadow.Foundation.Motors.BidirectionalDcMotor
BidirectionalDcMotor | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
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
Class BidirectionalDcMotor
A generic DC motor whose direction is dictated by two outputs (i.e. a pair of polarity relays)
Assembly: Meadow.Foundation.dll
View Source
Declaration
public class BidirectionalDcMotor
Properties
State
Gets the current run state of the motor
View Source
Declaration
public BidirectionalDcMotor.MotorState State { get; }
Methods
Stop()
Stop turning the motor
View Source
Declaration
public void Stop()
StartClockwise()
Start turning the motor clockwise
View Source
Declaration
public void StartClockwise()
StartCounterClockwise()
Start turning the motor counter/anti clockwise
View Source
Declaration
public void StartCounterClockwise()
Events
StateChanged
Occurs when the state of the motor changes
View Source
Declaration
public event EventHandler<BidirectionalDcMotor.MotorState> StateChanged
Event Type
System.EventHandler<Meadow.Foundation.Motors.BidirectionalDcMotor.MotorState>