Remarks

BidirectionalDcMotor
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

Characteristic Locus
Inheritance object > BidirectionalDcMotor
Inherited Members object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString()
Namespace Meadow.Foundation.Motors
Assembly Meadow.Foundation.dll

Syntax

public class BidirectionalDcMotor

Constructors

BidirectionalDcMotor(IDigitalOutputPort, IDigitalOutputPort, bool)

Creates an instance of an BiDirectionalDcMotor

Declaration
public BidirectionalDcMotor(IDigitalOutputPort outputA, IDigitalOutputPort outputB, bool energizeHigh = true)

Parameters

Type Name Description
IDigitalOutputPort outputA

The IDigitalOutputPort driving control relay A

IDigitalOutputPort outputB

The IDigitalOutputPort driving control relay B

bool energizeHigh

True if the relay control is positive logic, false if it's inverse logic

Remarks

BidirectionalDcMotor
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

Properties

State

Gets the current run state of the motor

Declaration
public BidirectionalDcMotor.MotorState State { get; }

Property Value

Type Description
BidirectionalDcMotor.MotorState

Remarks

BidirectionalDcMotor
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

Methods

StartClockwise()

Start turning the motor clockwise

Declaration
public void StartClockwise()

Remarks

BidirectionalDcMotor
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

StartCounterClockwise()

Start turning the motor counter/anti clockwise

Declaration
public void StartCounterClockwise()

Remarks

BidirectionalDcMotor
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

Stop()

Stop turning the motor

Declaration
public void Stop()

Remarks

BidirectionalDcMotor
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

Events

StateChanged

Occurs when the state of the motor changes

Declaration
public event EventHandler<BidirectionalDcMotor.MotorState> StateChanged

Event Type

Type Description
EventHandler<BidirectionalDcMotor.MotorState>

Remarks

BidirectionalDcMotor
Status Status badge: working
Source code GitHub
NuGet package NuGet 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