nanoFramework.System.Device.Pwm
1.0.1
Prefix Reserved
See the version list below for details.
dotnet add package nanoFramework.System.Device.Pwm --version 1.0.1
NuGet\Install-Package nanoFramework.System.Device.Pwm -Version 1.0.1
<PackageReference Include="nanoFramework.System.Device.Pwm" Version="1.0.1" />
paket add nanoFramework.System.Device.Pwm --version 1.0.1
#r "nuget: nanoFramework.System.Device.Pwm, 1.0.1"
// Install nanoFramework.System.Device.Pwm as a Cake Addin #addin nuget:?package=nanoFramework.System.Device.Pwm&version=1.0.1 // Install nanoFramework.System.Device.Pwm as a Cake Tool #tool nuget:?package=nanoFramework.System.Device.Pwm&version=1.0.1
Welcome to the .NET nanoFramework System.Device.Pwm Library repository
Build status
Component | Build Status | NuGet Package |
---|---|---|
System.Device.Pwm | ||
System.Device.Pwm (preview) |
Usage
You can create a PWM channel from a pin number, this is the recommended way. Keep in mind, you will have to allocate the pin in the case of ESP32 and make sure your pin is PWM enabled for STM32 devices.
// Case of ESP32, you need to set the pin function, in this example PWM3 for pin 18:
Configuration.SetPinFunction(18, DeviceFunction.PWM3);
PwmChannel pwmPin = PwmChannel.CreateFromPin(18, 40000);
// You can check then if it has created a valid one:
if (pwmPin != null)
{
// You do have a valid one
}
Duty cycle
You can adjust the duty cycle by using the property:
pwmPin.DutyCycle = 0.42;
The duty cycle goes from 0.0 to 1.0.
Frequency
It is recommended to setup the frequency when creating the PWM Channel. You can technically change it at any time but keep in mind some platform may not behave properly when adjusting this element.
Advance PwmChannel creation
You can as well, if you know the chip/timer Id and the channel use the create function:
PwmChannel pwmPin = new(1, 2, 40000, 0.5);
This is only recommended for advance users.
Other considerations
PWM precision may vary from platform to platform. It is highly recommended to check what precision can be achieved, either with the frequency, either with the duty cycle.
Feedback and documentation
For documentation, providing feedback, issues and finding out how to contribute please refer to the Home repo.
Join our Discord community here.
Credits
The list of contributors to this project can be found at CONTRIBUTORS.
License
The nanoFramework Class Libraries are licensed under the MIT license.
Code of Conduct
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behaviour in our community. For more information see the .NET Foundation Code of Conduct.
.NET Foundation
This project is supported by the .NET Foundation.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
-
- nanoFramework.CoreLibrary (>= 1.12.0)
NuGet packages (8)
Showing the top 5 NuGet packages that depend on nanoFramework.System.Device.Pwm:
Package | Downloads |
---|---|
nanoFramework.Iot.Device.Buzzer
This package includes the .NET IoT Core binding Iot.Device.Buzzer for .NET nanoFramework C# projects. |
|
nanoFramework.M5Core2
This package includes the nanoFramework.M5Core2 assembly for .NET nanoFramework C# projects. |
|
nanoFramework.MagicBit
This package includes nanoFramework.MagicBit, a board package library for MagicBit in .NET nanoFramework C# projects. |
|
nanoFramework.Iot.Device.DCMotor
This package includes the .NET IoT Core binding Iot.Device.DCMotor for .NET nanoFramework C# projects. |
|
nanoFramework.Iot.Device.ServoMotor
This package includes the .NET IoT Core binding Servo Motor for .NET nanoFramework C# projects. |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on nanoFramework.System.Device.Pwm:
Repository | Stars |
---|---|
nanoframework/Samples
🍬 Code samples from the nanoFramework team used in testing, proof of concepts and other explorational endeavours
|
|
nanoframework/nanoFramework.IoT.Device
📦 This repo includes .NET nanoFramework implementations for various sensors, chips, displays, hats and drivers
|
Version | Downloads | Last updated |
---|---|---|
1.1.10 | 12,687 | 11/9/2023 |
1.1.6 | 23,897 | 12/22/2022 |
1.1.4 | 308 | 12/22/2022 |
1.0.1 | 124,820 | 3/28/2022 |
1.0.1-preview.15 | 142 | 3/28/2022 |
1.0.1-preview.13 | 310 | 3/17/2022 |
1.0.1-preview.11 | 256 | 3/14/2022 |
1.0.1-preview.8 | 411 | 2/17/2022 |
1.0.1-preview.6 | 475 | 1/28/2022 |
1.0.1-preview.4 | 309 | 1/21/2022 |
1.0.0 | 2,143 | 12/23/2021 |
1.0.0-preview.20 | 256 | 12/2/2021 |
1.0.0-preview.18 | 172 | 11/30/2021 |
1.0.0-preview.14 | 989 | 9/21/2021 |
1.0.0-preview.12 | 196 | 9/20/2021 |
1.0.0-preview.10 | 170 | 9/20/2021 |