Remarks
Pca9685 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Pca9685 pca9685;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var i2CBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
pca9685 = new Pca9685(i2CBus, new Meadow.Units.Frequency(50, Meadow.Units.Frequency.UnitType.Hertz), (byte)Pca9685.Addresses.Default);
pca9685.Initialize();
return base.Initialize();
}
public override Task Run()
{
var port0 = pca9685.CreatePwmPort(0, 0.05f);
var port7 = pca9685.CreatePwmPort(7);
port0.Start();
port7.Start();
return base.Run();
}
Sample project(s) available on GitHub
Wiring Example
To wire a PCA9685 to your Meadow board, connect the following:
Characteristic | Locus |
---|---|
Inheritance | object > Pca9685 |
Implements | II2cPeripheral |
Inherited Members | object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString() |
Namespace | Meadow.Foundation.ICs.IOExpanders |
Assembly | Pca9685.dll |
Syntax
public class Pca9685 : II2cPeripheral
Constructors
Pca9685(II2cBus, Frequency, byte)
Create a new Pca9685 object
Declaration
public Pca9685(II2cBus i2cBus, Frequency frequency, byte address = 64)
Parameters
Type | Name | Description |
---|---|---|
II2cBus | i2cBus | The I2C bus connected to the peripheral |
Frequency | frequency | The frequency |
byte | address | The I2C address |
Remarks
Pca9685 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Pca9685 pca9685;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var i2CBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
pca9685 = new Pca9685(i2CBus, new Meadow.Units.Frequency(50, Meadow.Units.Frequency.UnitType.Hertz), (byte)Pca9685.Addresses.Default);
pca9685.Initialize();
return base.Initialize();
}
public override Task Run()
{
var port0 = pca9685.CreatePwmPort(0, 0.05f);
var port7 = pca9685.CreatePwmPort(7);
port0.Start();
port7.Start();
return base.Run();
}
Sample project(s) available on GitHub
Wiring Example
To wire a PCA9685 to your Meadow board, connect the following:
Pca9685(II2cBus, byte)
Create a new Pca9685 object
Declaration
public Pca9685(II2cBus i2cBus, byte address = 64)
Parameters
Type | Name | Description |
---|---|---|
II2cBus | i2cBus | The I2C bus connected to the peripheral |
byte | address | The I2C address |
Remarks
Pca9685 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Pca9685 pca9685;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var i2CBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
pca9685 = new Pca9685(i2CBus, new Meadow.Units.Frequency(50, Meadow.Units.Frequency.UnitType.Hertz), (byte)Pca9685.Addresses.Default);
pca9685.Initialize();
return base.Initialize();
}
public override Task Run()
{
var port0 = pca9685.CreatePwmPort(0, 0.05f);
var port7 = pca9685.CreatePwmPort(7);
port0.Start();
port7.Start();
return base.Run();
}
Sample project(s) available on GitHub
Wiring Example
To wire a PCA9685 to your Meadow board, connect the following:
Fields
i2cComms
I2C Communication bus used to communicate with the peripheral
Declaration
protected readonly II2cCommunications i2cComms
Field Value
Type | Description |
---|---|
II2cCommunications |
Remarks
Pca9685 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Pca9685 pca9685;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var i2CBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
pca9685 = new Pca9685(i2CBus, new Meadow.Units.Frequency(50, Meadow.Units.Frequency.UnitType.Hertz), (byte)Pca9685.Addresses.Default);
pca9685.Initialize();
return base.Initialize();
}
public override Task Run()
{
var port0 = pca9685.CreatePwmPort(0, 0.05f);
var port7 = pca9685.CreatePwmPort(7);
port0.Start();
port7.Start();
return base.Run();
}
Sample project(s) available on GitHub
Wiring Example
To wire a PCA9685 to your Meadow board, connect the following:
Properties
DefaultI2cAddress
The default I2C address for the peripheral
Declaration
public byte DefaultI2cAddress { get; }
Property Value
Type | Description |
---|---|
byte |
Remarks
Pca9685 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Pca9685 pca9685;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var i2CBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
pca9685 = new Pca9685(i2CBus, new Meadow.Units.Frequency(50, Meadow.Units.Frequency.UnitType.Hertz), (byte)Pca9685.Addresses.Default);
pca9685.Initialize();
return base.Initialize();
}
public override Task Run()
{
var port0 = pca9685.CreatePwmPort(0, 0.05f);
var port7 = pca9685.CreatePwmPort(7);
port0.Start();
port7.Start();
return base.Run();
}
Sample project(s) available on GitHub
Wiring Example
To wire a PCA9685 to your Meadow board, connect the following:
i2cBus
The I2C bus connected to the pca9685
Declaration
protected II2cBus i2cBus { get; set; }
Property Value
Type | Description |
---|---|
II2cBus |
Remarks
Pca9685 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Pca9685 pca9685;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var i2CBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
pca9685 = new Pca9685(i2CBus, new Meadow.Units.Frequency(50, Meadow.Units.Frequency.UnitType.Hertz), (byte)Pca9685.Addresses.Default);
pca9685.Initialize();
return base.Initialize();
}
public override Task Run()
{
var port0 = pca9685.CreatePwmPort(0, 0.05f);
var port7 = pca9685.CreatePwmPort(7);
port0.Start();
port7.Start();
return base.Run();
}
Sample project(s) available on GitHub
Wiring Example
To wire a PCA9685 to your Meadow board, connect the following:
Methods
CreatePwmPort(byte, float)
Create a IPwmPort on the specified pin
Declaration
public virtual IPwmPort CreatePwmPort(byte portNumber, float dutyCycle = 0.5)
Parameters
Type | Name | Description |
---|---|---|
byte | portNumber | The port number (0-15) |
float | dutyCycle | The duty cycle for that port |
Returns
Type | Description |
---|---|
IPwmPort | IPwmPort |
Remarks
Pca9685 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Pca9685 pca9685;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var i2CBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
pca9685 = new Pca9685(i2CBus, new Meadow.Units.Frequency(50, Meadow.Units.Frequency.UnitType.Hertz), (byte)Pca9685.Addresses.Default);
pca9685.Initialize();
return base.Initialize();
}
public override Task Run()
{
var port0 = pca9685.CreatePwmPort(0, 0.05f);
var port7 = pca9685.CreatePwmPort(7);
port0.Start();
port7.Start();
return base.Run();
}
Sample project(s) available on GitHub
Wiring Example
To wire a PCA9685 to your Meadow board, connect the following:
Initialize()
Initializes the PCA9685 IC
Declaration
public virtual void Initialize()
Remarks
Pca9685 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Pca9685 pca9685;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var i2CBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
pca9685 = new Pca9685(i2CBus, new Meadow.Units.Frequency(50, Meadow.Units.Frequency.UnitType.Hertz), (byte)Pca9685.Addresses.Default);
pca9685.Initialize();
return base.Initialize();
}
public override Task Run()
{
var port0 = pca9685.CreatePwmPort(0, 0.05f);
var port7 = pca9685.CreatePwmPort(7);
port0.Start();
port7.Start();
return base.Run();
}
Sample project(s) available on GitHub
Wiring Example
To wire a PCA9685 to your Meadow board, connect the following:
SetPin(byte, bool)
Turns the specified pin On or Off
Declaration
public virtual void SetPin(byte pin, bool on)
Parameters
Type | Name | Description |
---|---|---|
byte | pin | The pin to set |
bool | on | true is on, false if off |
Remarks
Pca9685 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Pca9685 pca9685;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var i2CBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
pca9685 = new Pca9685(i2CBus, new Meadow.Units.Frequency(50, Meadow.Units.Frequency.UnitType.Hertz), (byte)Pca9685.Addresses.Default);
pca9685.Initialize();
return base.Initialize();
}
public override Task Run()
{
var port0 = pca9685.CreatePwmPort(0, 0.05f);
var port7 = pca9685.CreatePwmPort(7);
port0.Start();
port7.Start();
return base.Run();
}
Sample project(s) available on GitHub
Wiring Example
To wire a PCA9685 to your Meadow board, connect the following:
SetPwm(byte, int, int)
Set the values for specified output pin.
Declaration
public virtual void SetPwm(byte pin, int on, int off)
Parameters
Type | Name | Description |
---|---|---|
byte | pin | The pwm Pin |
int | on | LED{X}_ON_L and LED{X}_ON_H register value |
int | off | LED{X}_OFF_L and LED{X}_OFF_H register value |
Remarks
On parameter is an inverted pwm signal