/Netduino-Button-LED

Controlling an LED with a switch using the original Netduino.

Primary LanguageC#

Button LED Example for Netduino

Controlling an LED with a switch using the original Netduino. Repository created for educational purposes.

What You'll Need

Software:

Parts:

  • Netduino 1
  • Two 220Ω Resistors
  • One LED
  • One Standard Breadboard
  • Seven Wires
  • One Switch

Breadboard

See Breadboard.svg

Image

Real-life Image

Code

var led = new OutputPort(Pins.GPIO_PIN_D13, false);
var button = new InputPort(Pins.GPIO_PIN_D2, false, Port.ResistorMode.Disabled);

while (true)
{
    if (!button.Read())
    {
        led.Write(!led.Read());
        Thread.Sleep(1000);
    }
}