Skip to main content

Meadow.Foundation.FeatherWings.MotorWing

MotorWing
StatusStatus badge: working
Source codeGitHub
Datasheet(s)GitHub
NuGet packageNuGet Gallery for Meadow.Foundation.FeatherWings.MotorWing

Code Example

MotorWing motorWing;

public override Task Initialize()
{
Console.WriteLine("Initializing ...");

var i2CBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
motorWing = new MotorWing(i2CBus, new Frequency(100, Frequency.UnitType.Hertz), 0x61);
motorWing.Initialize();

return Task.CompletedTask;
}

public override async Task Run()
{
//Get DC motor 1
var dcMotor1 = motorWing.GetMotor(1);

//Get DC motor 2
var dcMotor2 = motorWing.GetMotor(2);

//Get Stepper motor number 2
var stepper = motorWing.GetStepper(2, 200);

dcMotor1.Run(Commmand.FORWARD);
dcMotor2.Run(Commmand.BACKWARD);

while (true)
{
Console.WriteLine("Speed up");
for (short i = 0; i <= 255; i++)
{
dcMotor1.SetSpeed(i);
dcMotor2.SetSpeed(i);
await Task.Delay(10);
}

stepper.Step(50);

await Task.Delay(500);

Console.WriteLine("Slow down");
for (short i = 255; i >= 0; i--)
{
dcMotor1.SetSpeed(i);
dcMotor2.SetSpeed(i);
await Task.Delay(10);
}

stepper.Step(-50);

await Task.Delay(500);
}
}

Sample project(s) available on GitHub

Class MotorWing

Represents Adafruit's Feather DC and Stepper Motor Wing

Assembly: MotorWing.dll
View Source
Declaration
public class MotorWing

Methods

Initialize()

Initialize the MotorWings

View Source
Declaration
public void Initialize()

GetStepper(short, int)

Returns a instance of a Stepper Motor object

View Source
Declaration
public StepperMotor GetStepper(short stepperMotorIndex, int steps)
Returns

Meadow.Foundation.FeatherWings.StepperMotor: StepperMotor

Parameters
TypeNameDescription
System.Int16stepperMotorIndexThe stepper motor port we want to use: only 0 or 1 are valid
System.Int32stepsThe number of steps the motor has

GetMotor(short)

Returns a instance of a DC Motor object

View Source
Declaration
public DCMotor GetMotor(short dcMotorIndex)
Returns

Meadow.Foundation.FeatherWings.DCMotor: DCMotor

Parameters
TypeNameDescription
System.Int16dcMotorIndexThe motor port we want to use: 1 thru 4 are valid