NCIR
01
.:Getting Started:.
.:Blinking LED:.
(NEDX) .:Netduino Experimentation Kit:. (NEDX)

What We're Doing
LEDs (light emitting diodes) are used in all sorts of clever things which is why we have included them in this kit. We will start off with something very simple, simply extending our getting started program to an externally wired LED. To get started, grab the parts listed below, pin the layout sheet to your breadboard and then plug everything in. Once the circuit is assembled you'll need to open a new Netduino application in Visual C# (like in the getting started program) and load the new program onto the Netduino (remember to switch the target from emulator to NetDuino then press F5)

If you are having trouble a full video walkthrough of this program can be found here: http://nedx.org/TRBL


The Circuit
The Parts
NCIR-01
Breadboard Sheet
x1
2 Pin Header
x4
10mm LED
x1
Wire
560 Ohm Resistor
Green-Blue-Brown
x1


Schematic

 

Resources
.:download:.
breadboard layout sheet
http://nedx.org/NBLS01

 

Code (no need to type everything in just)
Download from ( http://nedx.org/CODE01 )
//Libraries that our program uses
using System;                               //use base classes                            
using System.Threading;                     //use threading classes        
using Microsoft.SPOT;                       //use smart personal objects technology classes
using Microsoft.SPOT.Hardware;              //use hardware related SPOT classes
using SecretLabs.NETMF.Hardware;            //use Secret Labs hardware framework
using SecretLabs.NETMF.Hardware.Netduino;   //use the Netduino specific classes

namespace NCIR01                    /// Define the namespace we are in ///
{
    public class Program                    
    {
        public static void Main()   /// The Main loop (run at power up) ///
        {
/// Setup Portion of Program, runs once at startup ///
            OutputPort led = new OutputPort(Pins.GPIO_PIN_D13, false);      
               //define our LED as being connected to pin 13
            while (true)            /// Do Forever ///
            {
                led.Write(true);            //turn led on
                Thread.Sleep(100);          //wait 250 milliseconds
                led.Write(false);           //turn light off
                Thread.Sleep(100);          //wait 250 milliseconds
            }                       /// Close Forever Loop ///        
        }                           /// Close the Main() Loop ///
    }                               /// Close the Program Loop ///
}                                   /// Close the Namespace Loop ///

 

Not Working? (3 things to try)
 

 
LED Not Lighting Up?
LEDs will only work in one direction. Try taking it out and twisting it 180 degrees.
(no need to worry, installing it backwards does no permanent harm).
 
Program Not Running?
If a black box appears when you start debuggin
 
Can't Change the Code?
To make changes to the code you must first stop Debugging.
Debug > Stop Debugging
(Shift F5)
 
 

Making it Better?
 
Changing the pin:
We've connected the LED to pin 13 but we can use any of the Netduino's digital pins. To change it take the wire plugged into pin 13 and move it to a pin of your choice (from 0-13)

Then in the code change the line:
OutputPort led = new OutputPort(Pins.GPIO_PIN_D13, false)
|
OutputPort led = new OutputPort(Pins.GPIO_PIN_D--, false)
-- = new pin number


Then debug the app: (F5)

Change the blink time:
Unhappy with 1/4 second on 1/4 second off?

In the code change the the two lines:
Thread.Sleep(250)
|
Thread.Sleep(---) --- =
Delay in milliseconds

Control the brightness:
Along with digital (on/off) control the Netduino can control some pins in an analog (brightness) fashion. (more details on this in later circuits). To play around with it.





Change the LED to pin 9 and set it as a PWM output:

OutputPort led = new OutputPort(Pins.GPIO_PIN_D13, false);
|

PWM pwm = new PWM(Pins.GPIO_PIN_D9);

.:also change the wire:.


Replace the code inside the { }'s of while (true) with this:
pwm.SetDutyCycle(new number);



(new number) = any number between 0 and 100.
0 = off, 100 = on, in between = different brightness

Fading:

Copy and Paste the code from http://nedx.org/NCIRMB

Then start debugging (F5) to watch the LED fade in and then out.

Making Even Better:

Trying playing around with some of the values. Don't worry it is very difficult to break anything.