Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
Characteristic | Locus |
---|---|
Inheritance | object > RgbPwmLed |
Implements | IRgbPwmLed |
Inherited Members | object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString() |
Namespace | Meadow.Foundation.Leds |
Assembly | Meadow.Foundation.dll |
Syntax
public class RgbPwmLed : IRgbPwmLed
Constructors
RgbPwmLed(IPin, IPin, IPin, CommonType)
Create instance of RgbPwmLed
Declaration
public RgbPwmLed(IPin redPwmPin, IPin greenPwmPin, IPin bluePwmPin, CommonType commonType = CommonType.CommonCathode)
Parameters
Type | Name | Description |
---|---|---|
IPin | redPwmPin | The PWM pin for the red LED |
IPin | greenPwmPin | The PWM pin for the green LED |
IPin | bluePwmPin | The PWM pin for the blue LED |
CommonType | commonType | Common anode or common cathode |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
RgbPwmLed(IPin, IPin, IPin, Voltage, Voltage, Voltage, CommonType)
Create instance of RgbPwmLed
Declaration
public RgbPwmLed(IPin redPwmPin, IPin greenPwmPin, IPin bluePwmPin, Voltage redLedForwardVoltage, Voltage greenLedForwardVoltage, Voltage blueLedForwardVoltage, CommonType commonType = CommonType.CommonCathode)
Parameters
Type | Name | Description |
---|---|---|
IPin | redPwmPin | The PWM pin for the red LED |
IPin | greenPwmPin | The PWM pin for the green LED |
IPin | bluePwmPin | The PWM pin for the blue LED |
Voltage | redLedForwardVoltage | The forward voltage for the red LED |
Voltage | greenLedForwardVoltage | The forward voltage for the green LED |
Voltage | blueLedForwardVoltage | The forward voltage for the blue LED |
CommonType | commonType | Common anode or common cathode |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
RgbPwmLed(IPwmPort, IPwmPort, IPwmPort, CommonType)
Create instance of RgbPwmLed
Declaration
public RgbPwmLed(IPwmPort redPwmPort, IPwmPort greenPwmPort, IPwmPort bluePwmPort, CommonType commonType = CommonType.CommonCathode)
Parameters
Type | Name | Description |
---|---|---|
IPwmPort | redPwmPort | The PWM port for the red LED |
IPwmPort | greenPwmPort | The PWM port for the green LED |
IPwmPort | bluePwmPort | The PWM port for the blue LED |
CommonType | commonType | Common anode or common cathode |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
RgbPwmLed(IPwmPort, IPwmPort, IPwmPort, Voltage, Voltage, Voltage, CommonType)
Create instance of RgbPwmLed
Declaration
public RgbPwmLed(IPwmPort redPwmPort, IPwmPort greenPwmPort, IPwmPort bluePwmPort, Voltage redLedForwardVoltage, Voltage greenLedForwardVoltage, Voltage blueLedForwardVoltage, CommonType commonType = CommonType.CommonCathode)
Parameters
Type | Name | Description |
---|---|---|
IPwmPort | redPwmPort | The PWM port for the red LED |
IPwmPort | greenPwmPort | The PWM port for the green LED |
IPwmPort | bluePwmPort | The PWM port for the blue LED |
Voltage | redLedForwardVoltage | The forward voltage for the red LED |
Voltage | greenLedForwardVoltage | The forward voltage for the green LED |
Voltage | blueLedForwardVoltage | The forward voltage for the blue LED |
CommonType | commonType | Common anode or common cathode |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
Properties
BlueForwardVoltage
The blue LED forward voltage
Declaration
public Voltage BlueForwardVoltage { get; protected set; }
Property Value
Type | Description |
---|---|
Voltage |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
BluePwm
The blue LED port
Declaration
protected IPwmPort BluePwm { get; set; }
Property Value
Type | Description |
---|---|
IPwmPort |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
Brightness
The brightness value assigned to the LED
Declaration
public float Brightness { get; protected set; }
Property Value
Type | Description |
---|---|
float |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
Color
The current LED color
Declaration
public Color Color { get; protected set; }
Property Value
Type | Description |
---|---|
Color |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
Common
The common type (common anode or common cathode)
Declaration
public CommonType Common { get; protected set; }
Property Value
Type | Description |
---|---|
CommonType |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
GreenForwardVoltage
The green LED forward voltage
Declaration
public Voltage GreenForwardVoltage { get; protected set; }
Property Value
Type | Description |
---|---|
Voltage |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
GreenPwm
The green LED port
Declaration
protected IPwmPort GreenPwm { get; set; }
Property Value
Type | Description |
---|---|
IPwmPort |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
IsOn
Turns on LED with current color or turns it off
Declaration
public bool IsOn { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
MAX_FORWARD_VOLTAGE
Maximum forward voltage (3.3 Volts)
Declaration
public Voltage MAX_FORWARD_VOLTAGE { get; }
Property Value
Type | Description |
---|---|
Voltage |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
MIN_FORWARD_VOLTAGE
Minimum forward voltage (0 Volts)
Declaration
public Voltage MIN_FORWARD_VOLTAGE { get; }
Property Value
Type | Description |
---|---|
Voltage |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
RedForwardVoltage
The red LED forward voltage
Declaration
public Voltage RedForwardVoltage { get; protected set; }
Property Value
Type | Description |
---|---|
Voltage |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
RedPwm
The red LED port
Declaration
protected IPwmPort RedPwm { get; set; }
Property Value
Type | Description |
---|---|
IPwmPort |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
Methods
ResetPwmPorts()
Resets all PWM ports
Declaration
protected void ResetPwmPorts()
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
SetBrightness(float)
Set the led brightness
Declaration
public void SetBrightness(float brightness)
Parameters
Type | Name | Description |
---|---|---|
float | brightness | Valid values are from 0 to 1, inclusive |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
SetColor(Color, float)
Sets the current color of the LED
Declaration
public void SetColor(Color color, float brightness = 1)
Parameters
Type | Name | Description |
---|---|---|
Color | color | The LED color |
float | brightness | Valid values are from 0 to 1, inclusive |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
StartBlink(Color, float, float)
Start the Blink animation which sets the brightness of the LED alternating between a low and high brightness On an interval of 1 second (500ms on, 500ms off)
Declaration
public Task StartBlink(Color color, float highBrightness = 1, float lowBrightness = 0)
Parameters
Type | Name | Description |
---|---|---|
Color | color | The LED color |
float | highBrightness | The maximum brightness of the animation |
float | lowBrightness | The minimum brightness of the animation |
Returns
Type | Description |
---|---|
Task |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
StartBlink(Color, TimeSpan, TimeSpan, float, float)
Start the Blink animation which sets the brightness of the LED alternating between a low and high brightness setting, using the durations provided.
Declaration
public Task StartBlink(Color color, TimeSpan onDuration, TimeSpan offDuration, float highBrightness = 1, float lowBrightness = 0)
Parameters
Type | Name | Description |
---|---|---|
Color | color | The LED color |
TimeSpan | onDuration | The duration the LED stays on |
TimeSpan | offDuration | The duration the LED stays off |
float | highBrightness | The maximum brightness of the animation |
float | lowBrightness | The minimum brightness of the animation |
Returns
Type | Description |
---|---|
Task |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
StartBlink(float, float)
Start the Blink animation which sets the brightness of the LED alternating between a low and high brightness On an interval of 1 second (500ms on, 500ms off)
Declaration
public Task StartBlink(float highBrightness = 1, float lowBrightness = 0)
Parameters
Type | Name | Description |
---|---|---|
float | highBrightness | The maximum brightness of the animation |
float | lowBrightness | The minimum brightness of the animation |
Returns
Type | Description |
---|---|
Task |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
StartBlink(TimeSpan, TimeSpan, float, float)
Start the Blink animation which sets the brightness of the LED alternating between a low and high brightness setting, using the durations provided.
Declaration
public Task StartBlink(TimeSpan onDuration, TimeSpan offDuration, float highBrightness = 1, float lowBrightness = 0)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | onDuration | The duration the LED stays on |
TimeSpan | offDuration | The duration the LED stays off |
float | highBrightness | The maximum brightness of the animation |
float | lowBrightness | The minimum brightness of the animation |
Returns
Type | Description |
---|---|
Task |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
StartPulse(Color, float, float)
Start the Pulse animation which gradually alternates the brightness of the LED between a low and high brightness setting with a cycle time of 600ms
Declaration
public Task StartPulse(Color color, float highBrightness = 1, float lowBrightness = 0.15)
Parameters
Type | Name | Description |
---|---|---|
Color | color | The LED color |
float | highBrightness | The maximum brightness of the animation |
float | lowBrightness | The minimum brightness of the animation |
Returns
Type | Description |
---|---|
Task |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
StartPulse(Color, TimeSpan, float, float)
Start the Pulse animation which gradually alternates the brightness of the LED between a low and high brightness setting, using the durations provided.
Declaration
public Task StartPulse(Color color, TimeSpan pulseDuration, float highBrightness = 1, float lowBrightness = 0.15)
Parameters
Type | Name | Description |
---|---|---|
Color | color | The LED color |
TimeSpan | pulseDuration | The pulse animation duration |
float | highBrightness | The maximum brightness of the animation |
float | lowBrightness | The minimum brightness of the animation |
Returns
Type | Description |
---|---|
Task |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
StartPulse(float, float)
Start the Pulse animation which gradually alternates the brightness of the LED between a low and high brightness setting with a cycle time of 600ms
Declaration
public Task StartPulse(float highBrightness = 1, float lowBrightness = 0.15)
Parameters
Type | Name | Description |
---|---|---|
float | highBrightness | The maximum brightness of the animation |
float | lowBrightness | The minimum brightness of the animation |
Returns
Type | Description |
---|---|
Task |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
StartPulse(TimeSpan, float, float)
Start the Pulse animation which gradually alternates the brightness of the LED between a low and high brightness setting, using the durations provided.
Declaration
public Task StartPulse(TimeSpan pulseDuration, float highBrightness = 1, float lowBrightness = 0.15)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | pulseDuration | The pulse animation duration |
float | highBrightness | The maximum brightness of the animation |
float | lowBrightness | The minimum brightness of the animation |
Returns
Type | Description |
---|---|
Task |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
StopAnimation()
Stops the current LED animation
Declaration
public Task StopAnimation()
Returns
Type | Description |
---|---|
Task |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
ValidateBrightness(float, float)
Validates LED brightness to ensure they're within the range 0 (off) - 1 (full brightness)
Declaration
protected void ValidateBrightness(float highBrightness, float lowBrightness)
Parameters
Type | Name | Description |
---|---|---|
float | highBrightness | The maximum brightness of the animation |
float | lowBrightness | The minimum brightness of the animation |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"
ValidateForwardVoltages(Voltage, Voltage, Voltage)
Validates forward voltages to ensure they're within the range MIN_FORWARD_VOLTAGE to MAX_FORWARD_VOLTAGE
Declaration
protected void ValidateForwardVoltages(Voltage redLedForwardVoltage, Voltage greenLedForwardVoltage, Voltage blueLedForwardVoltage)
Parameters
Type | Name | Description |
---|---|---|
Voltage | redLedForwardVoltage | The forward voltage for the red LED |
Voltage | greenLedForwardVoltage | The forward voltage for the green LED |
Voltage | blueLedForwardVoltage | The forward voltage for the blue LED |
Remarks
RgbPwmLed | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
RgbPwmLed represents an RGB LED whose color is controlled by the duty-cycle of three PWM signals. Can be used both with LEDs that have been current limited with in-series resistors, or LEDs without resistors.
Controlling an RGB LED via a PWM signal is more power efficient than using a current-limiting resistor, and it provides more control; allowing thousands of different colors, as opposed to the 8 colors of non-PWM powered RGB LED.
To use without resistors, pass in the forward voltages (voltage drop) of each of the LED components to the redLedForwardVoltage
, greenLedForwardVoltage
, and blueLedForwardVoltage
, constructor parameters, and the class will limit its output to the maximum forward voltage rating for those LEDs.
To use with an LED that has a resistor in series, pass 0.0
or TypicalForwardVoltage.ResistorLimited
for the forwardVoltage
parameter.
Code Example
RgbPwmLed onboardLed;
public override Task Initialize()
{
Resolver.Log.Info("Creating peripherals...");
onboardLed = new RgbPwmLed(
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue);
return Task.CompletedTask;
}
public override Task Run()
{
return TestColors();
}
public async Task TestColors()
{
while (true)
{
Resolver.Log.Info("SetColor(RgbLedColors.Red);");
onboardLed.SetColor(Color.Red);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse();");
await onboardLed.StartPulse();
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Green);");
await onboardLed.StartPulse(Color.Green);
await Task.Delay(3000);
Resolver.Log.Info("SetColor(RgbLedColors.Yellow);");
onboardLed.SetColor(Color.Yellow);
await Task.Delay(3000);
Resolver.Log.Info("StartPulse(RgbLedColors.Cyan, 200, 200);");
await onboardLed.StartPulse(Color.Cyan, TimeSpan.FromMilliseconds(400));
await Task.Delay(3000);
await onboardLed.StopAnimation();
}
}
Sample project(s) available on GitHub
Example Code
The following example code loops through the entire 360º of hue spectrum and displays that color on the RGB LED.
public MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
// create a new RgbPwmLed on pin 8
var pwmLed = new RgbPwmLed(
redPin: Device.Pins.D11,
greenPin: Device.Pins.D10,
bluePin: Device.Pins.D09,
redLedForwardVoltage: 1.05f,
greenLedForwardVoltage: 1.5f,
blueLedForwardVoltage: 1.5f);
);
// alternate between blinking and pulsing the LED
while (true)
{
for (int i = 0; i < 360; i++)
{
var hue = ((double)i / 360F);
Debug.Print(hue.ToString());
// set the color of the RGB
rgbPwmLed.SetColor(Color.FromHsba(((double)i / 360F), 1, 1));
// for a fun, fast rotation through the hue spectrum:
//Thread.Sleep (1);
// for a gentle walk through the forest of colors;
Thread.Sleep(18);
}
}
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Leds.RgbPwmLed/RgbPwmLed_Fritzing.svg"