Our Cookies Policy
To make full use of www.electromaker.io, enjoy the personalised features and ensure the websites works to its full potential, your computer, tablet or mobile phone will need to accept cookies.
Our cookies don’t store sensitive information such as your name, address or payment details: they simply hold information about how you use our site so we can improve your experience and resolve any errors.
If you’d prefer to restrict, block or delete cookies from www.electromaker.io, or any other website, you can use your browser to do this. Each browser is different, so check the ‘Help’ menu of your particular browser (or your mobile phone’s handset manual) to learn how to change your cookie preferences.
Here’s a list of the main cookies we use, and what we use them for:
Electromaker – Login session
Google Analytics – Analytics
Twitter – Twitter Feed
Each web browser handles cookie management differently, please follow instructions for your chosen browser:
This project shows you how to control the brightness of a generic LED using Pulse Width Modulation. We'll use the Pulse Width Modulation library included in Netduino.Foundationto make driving an LED quick and easy.
Pulse With Modulationis a way of controlling voltage digitally to emulate an analog signal. Netduino boards generate this signal as a square wave. The two key parameters under the control of the developer are the frequency and duty cycle. You can read more here.
In the above diagram, the time where the signal is high is the same as the time where the signal is low. The percentage of time the signal is on (high) is called the duty cycle. So, in the above, the signal is high 50% of the one cycle and so the duty cycle is 50%.
Netduino.Foundation is a platform for quickly and easily build connected things using the.NET MicroFramework on Netduino. Created by Wilderness Labs, it's completely open source and maintained by the Netduino community.
If you're new in Netduino development, I suggest you go to the Getting started with Netduinoproject to properly set up your development environment.
Assemble the circuit
For this project, simply connect the LED's cathode (short pin) to the GND, and the anode (long pin) to the pin 11 on your Netduino.
PwmLed circuit diagram
Create a Netduino project
Create a Netduino project in Visual Studio 2015 for Windows or the latest Visual Studio for Mac; name the project PwmLed.
Add the Netduino.Foundation NuGet Package
Right-click on your PwmLed project and click Manage Nuget Packages. In the Browse tab, search for Netduino.Foundation; it should be the first search result. Click the Install button.
Adding Netduino.Foundation nuget package
Alt-click on your PwmLed project in the Solution Explorer , and click Add => Add Nuget Packageto open the NuGet Package window. Search for the Netduino.Foundationpackage and click Add Packageto add it to your project.
Adding Netduino.Foundation nuget package
Control the LED
You'll use the Pulse Width Modulation library contained in Netduino.Foundationto control the brightness of your LED. Add theNetduino.Foundationnamepace: add a using statement for SecretLabs.NETMF.Hardware.Netduino. The code below uses an Alias named N.
In the Main method, create a new PwmLed object named pwdLed. In the constructor, specify the pin you're using to control the LED (pin 11) and the color of the LED (to select an appropriate voltage).
Using pwmLed, you can now invoke different APIs to light up your LED, such as StartBlink, StartPulse, or SetBrightness. These methods include parameters to control the LED behavior such as duration, high brightness and low brightness.
using N = SecretLabs.NETMF.Hardware.Netduino;
public class Program
public static void Main()
var pwmLed = new PwmLed
// pulse the LED
// keep the app running
Run the project
Click the run button in Visual Studio to see your LED pulse! It should be similar to the following gif:
White LED in a Pulse animation with PWM
Check out Netduino.Foundation!
This project is only the tip of the iceberg in terms of the extensive exciting things you can do with Netduino.Foundation.
It comes with a Huge Peripheral Driver Library with drivers for the most common sensors and peripherals available in the market.
All the peripheral drivers are simplified with built-in functionality, exposed by a clean, modern API.
This project is backed by a growing community that is constantly working on building cool connected things and always excited to help new-comers and discuss new projects.