Control LED in C# .NET using Netduino

Going further to explain Control LED in C# .NET using Netduino. Did you know that you can use Netduino to turn on an LED when you press a button? Well, It is true, you can do this! Leaving the joke aside, let me show how you can achieve this.

The button in the middle of the board (Pins.ONBOARD_BTN) is just another port that you can read using the .Net MF libraries. This simple example loops and reads the status of the button. If it’s down it returns true, Up returns false. Running the program and pressing the button just toggles the LED ON and OFF.

Source Code To Control LED in C# .NET using Netduino

using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace LED_Control_Using_Switch
    public class Program
        public static void Main()
            OutputPort onBoardLED = new OutputPort(Pins.ONBOARD_LED, false);
            InputPort inputPort = new InputPort(Pins.ONBOARD_BTN, false, Port.ResistorMode.Disabled);


It would be interesting to knock up a little app that recorded a pattern of button presses. After recording, it loops, waiting for you to press the button in the same sequence. If you do, it will light up the LED. You could imagine this connected to some sensor measuring a secret knock-knock password or a keyboard with which you play some musical notes.

If you get it right, it unlocks something like a box for instance. It might also be a nice way for sending morse code.

Many times I saw that people who is more comforatble in Dot Net, C# they stuck and say now who will learn C or C++, So for those kind of people it’s really good news that they can work on embebed system using their own favourite language C Sharp. So Let’s Cheers…

Control LED in C# .NET using Netduino

Getting Started with Netduino. Learn IoT using C# .NET

How To Use DS18B20 Water Proof Temperature Sensor

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on whatsapp
Share on telegram
Share on reddit
Share on tumblr
Related Posts
About Author

Leave a Comment

Your email address will not be published. Required fields are marked *