Remarks
MotorWing | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
public class MeadowApp : App<F7Micro, MeadowApp>
{
MotorWing motorWing;
public MeadowApp()
{
Initialize();
Run();
}
void Initialize()
{
Console.WriteLine("Initialize hardware...");
var i2CBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
motorWing = new MotorWing(i2CBus, 0x61);
motorWing.Initialize();
}
void 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);
Thread.Sleep(10);
}
stepper.Step(50);
Thread.Sleep(500);
Console.WriteLine("Slow down");
for (short i = 255; i >= 0; i--)
{
dcMotor1.SetSpeed(i);
dcMotor2.SetSpeed(i);
Thread.Sleep(10);
}
stepper.Step(-50);
Thread.Sleep(500);
}
}
}
Characteristic | Locus |
---|---|
Inheritance | System.Object > MotorWing |
Inherited Members | System.Object.ToString() System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone() |
Namespace | Meadow.Foundation.FeatherWings |
Assembly | MotorWing.dll |
Syntax
public class MotorWing
Constructors
MotorWing(II2cBus, Byte, Int32)
Declaration
public MotorWing(II2cBus i2cBus, byte address = 96, int frequency = 1600)
Parameters
Type | Name | Description |
---|---|---|
II2cBus | i2cBus | i2c bus |
System.Byte | address | The address of the i2c Peripheral |
System.Int32 | frequency |
Methods
GetMotor(Int16)
Returns a instance of a DC Motor object
Declaration
public DCMotor GetMotor(short dcMotorIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int16 | dcMotorIndex | The motor port we want to use: 1 thru 4 are valid |
Returns
Type | Description |
---|---|
DCMotor | DCMotor |
GetStepper(Int16, Int32)
Returns a instance of a Stepper Motor object
Declaration
public StepperMotor GetStepper(short stepperMotorIndex, int steps)
Parameters
Type | Name | Description |
---|---|---|
System.Int16 | stepperMotorIndex | The stepper motor port we want to use: only 0 or 1 are valid |
System.Int32 | steps | The number of steps the motor has |
Returns
Type | Description |
---|---|
StepperMotor | StepperMotor |
Initialize()
Initialize the PCA9685
Declaration
public void Initialize()