Meadow.Foundation.FeatherWings.MotorWing
| MotorWing | |
|---|---|
| Status | |
| Source code | GitHub |
| Datasheet(s) | GitHub |
| NuGet package |
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);
return Task.CompletedTask;
}
public override async Task Run()
{
//Get DC motor 1
var dcMotor1 = motorWing.GetMotor(MotorWing.DCMotorIndex.Motor1);
//Get DC motor 2
var dcMotor2 = motorWing.GetMotor(MotorWing.DCMotorIndex.Motor2);
//Get Stepper motor number 2
var stepper = motorWing.GetStepper(MotorWing.StepperMotorIndex.Motor2, 200);
dcMotor1.Run(MotorWing.Direction.Forward);
dcMotor2.Run(MotorWing.Direction.Reverse);
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
API Reference
Class MotorWing
Represents Adafruit's Feather DC and Stepper Motor Wing
Assembly: MotorWing.dll
View Source
Declaration
public class MotorWing
Methods
GetStepper(StepperMotorIndex, int)
Returns a instance of a Stepper Motor object
View Source
Declaration
public StepperMotor GetStepper(MotorWing.StepperMotorIndex motorIndex, int steps)
Returns
Meadow.Foundation.FeatherWings.StepperMotor: StepperMotor
Parameters
| Type | Name | Description |
|---|---|---|
| Meadow.Foundation.FeatherWings.MotorWing.StepperMotorIndex | motorIndex | The stepper motor port |
System.Int32 | steps | The number of steps the motor has |
GetMotor(DCMotorIndex)
Returns a instance of a DC Motor object
View Source
Declaration
public DCMotor GetMotor(MotorWing.DCMotorIndex motorIndex)
Returns
Meadow.Foundation.FeatherWings.DCMotor: DCMotor
Parameters
| Type | Name | Description |
|---|---|---|
| Meadow.Foundation.FeatherWings.MotorWing.DCMotorIndex | motorIndex | The motor port |