Remarks
ServoWing | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
ServoWing servoWing;
Servo servo;
public override Task Initialize()
{
Console.WriteLine("Initializng ...");
servoWing = new ServoWing(Device.CreateI2cBus(I2cBusSpeed.FastPlus));
servo = servoWing.GetServo(0, NamedServoConfigs.SG90);
return Task.CompletedTask;
}
public override async Task Run()
{
while (true)
{
Console.WriteLine("0");
await servo.RotateTo(new Angle(0, AU.Degrees));
await Task.Delay(1000);
Console.WriteLine("45");
await servo.RotateTo(new Angle(45, AU.Degrees));
await Task.Delay(1000);
Console.WriteLine("90");
await servo.RotateTo(new Angle(90, AU.Degrees));
await Task.Delay(1000);
Console.WriteLine("135");
await servo.RotateTo(new Angle(135, AU.Degrees));
await Task.Delay(1000);
}
}
Sample project(s) available on GitHub
Characteristic | Locus |
---|---|
Inheritance | object > ServoWing |
Inherited Members | object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString() |
Namespace | Meadow.Foundation.FeatherWings |
Assembly | ServoWing.dll |
Syntax
public class ServoWing
Constructors
ServoWing(II2cBus, Frequency, byte, short)
Creates a ServoWing driver
Declaration
public ServoWing(II2cBus i2cBus, Frequency frequency, byte address = 64, short portCount = 8)
Parameters
Type | Name | Description |
---|---|---|
II2cBus | i2cBus | |
Frequency | frequency | |
byte | address | |
short | portCount |
Remarks
ServoWing | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
ServoWing servoWing;
Servo servo;
public override Task Initialize()
{
Console.WriteLine("Initializng ...");
servoWing = new ServoWing(Device.CreateI2cBus(I2cBusSpeed.FastPlus));
servo = servoWing.GetServo(0, NamedServoConfigs.SG90);
return Task.CompletedTask;
}
public override async Task Run()
{
while (true)
{
Console.WriteLine("0");
await servo.RotateTo(new Angle(0, AU.Degrees));
await Task.Delay(1000);
Console.WriteLine("45");
await servo.RotateTo(new Angle(45, AU.Degrees));
await Task.Delay(1000);
Console.WriteLine("90");
await servo.RotateTo(new Angle(90, AU.Degrees));
await Task.Delay(1000);
Console.WriteLine("135");
await servo.RotateTo(new Angle(135, AU.Degrees));
await Task.Delay(1000);
}
}
ServoWing(II2cBus, byte, short)
Creates a ServoWing driver
Declaration
public ServoWing(II2cBus i2cBus, byte address = 64, short portCount = 8)
Parameters
Type | Name | Description |
---|---|---|
II2cBus | i2cBus | |
byte | address | |
short | portCount |
Remarks
ServoWing | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
ServoWing servoWing;
Servo servo;
public override Task Initialize()
{
Console.WriteLine("Initializng ...");
servoWing = new ServoWing(Device.CreateI2cBus(I2cBusSpeed.FastPlus));
servo = servoWing.GetServo(0, NamedServoConfigs.SG90);
return Task.CompletedTask;
}
public override async Task Run()
{
while (true)
{
Console.WriteLine("0");
await servo.RotateTo(new Angle(0, AU.Degrees));
await Task.Delay(1000);
Console.WriteLine("45");
await servo.RotateTo(new Angle(45, AU.Degrees));
await Task.Delay(1000);
Console.WriteLine("90");
await servo.RotateTo(new Angle(90, AU.Degrees));
await Task.Delay(1000);
Console.WriteLine("135");
await servo.RotateTo(new Angle(135, AU.Degrees));
await Task.Delay(1000);
}
}
Methods
GetContinuousRotatioServo(byte, ServoConfig)
Returns the specified continues rotation servo
Declaration
public IContinuousRotationServo GetContinuousRotatioServo(byte portIndex, ServoConfig servoConfig)
Parameters
Type | Name | Description |
---|---|---|
byte | portIndex | |
ServoConfig | servoConfig |
Returns
Type | Description |
---|---|
IContinuousRotationServo |
Remarks
ServoWing | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
ServoWing servoWing;
Servo servo;
public override Task Initialize()
{
Console.WriteLine("Initializng ...");
servoWing = new ServoWing(Device.CreateI2cBus(I2cBusSpeed.FastPlus));
servo = servoWing.GetServo(0, NamedServoConfigs.SG90);
return Task.CompletedTask;
}
public override async Task Run()
{
while (true)
{
Console.WriteLine("0");
await servo.RotateTo(new Angle(0, AU.Degrees));
await Task.Delay(1000);
Console.WriteLine("45");
await servo.RotateTo(new Angle(45, AU.Degrees));
await Task.Delay(1000);
Console.WriteLine("90");
await servo.RotateTo(new Angle(90, AU.Degrees));
await Task.Delay(1000);
Console.WriteLine("135");
await servo.RotateTo(new Angle(135, AU.Degrees));
await Task.Delay(1000);
}
}
Exceptions
Type | Condition |
---|---|
ArgumentException |
GetServo(byte, ServoConfig)
Returns the specified servo
Declaration
public Servo GetServo(byte portIndex, ServoConfig servoConfig)
Parameters
Type | Name | Description |
---|---|---|
byte | portIndex | |
ServoConfig | servoConfig |
Returns
Type | Description |
---|---|
Servo |
Remarks
ServoWing | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
ServoWing servoWing;
Servo servo;
public override Task Initialize()
{
Console.WriteLine("Initializng ...");
servoWing = new ServoWing(Device.CreateI2cBus(I2cBusSpeed.FastPlus));
servo = servoWing.GetServo(0, NamedServoConfigs.SG90);
return Task.CompletedTask;
}
public override async Task Run()
{
while (true)
{
Console.WriteLine("0");
await servo.RotateTo(new Angle(0, AU.Degrees));
await Task.Delay(1000);
Console.WriteLine("45");
await servo.RotateTo(new Angle(45, AU.Degrees));
await Task.Delay(1000);
Console.WriteLine("90");
await servo.RotateTo(new Angle(90, AU.Degrees));
await Task.Delay(1000);
Console.WriteLine("135");
await servo.RotateTo(new Angle(135, AU.Degrees));
await Task.Delay(1000);
}
}