FEZ Project 1–LED Driver

So you got your FEZ and downloaded your firmware and ran some sample code.  Now what?  If you like the most of us, you want to drive a LED and have turn on and off or blink at your command.  You can drive LEDs (about 6 total) directly from the signal pins.  The CPU pins are 3.3v outputs and low amps.  You only drive about 6 directly hooked up to separate pins because the board has limited amps. CPU pins are not really designed to source devices so there is limited amps to go around.  If we want to be on the safe side, we want to drive any device from a separate voltage bus.  The easiest way to do this is using a MOSFET.  One side of the MOSFET has our separate voltage and the Gate (i.e. logic level side) is driven open and closed by a pin on the FEZ.  Now we don’t have to worry about over draining a CPU pin, and drive other higher power devices like motors this way.  Remember when using LEDs to select the proper resistor so you don’t burn out your lamp.  At 3-5v, 330 ohm is usually a safe bet, but check your LED datasheet.

Now let some code fly and blink that LED.

private static void TestLedBlink()
{
    PWM pwm = new PWM((PWM.Pin)FEZ_Pin.PWM.Di8);
    pwm.Set(2, 50);     // every quarter second blink.
    Thread.Sleep(6000); // let it blink for 6secs.
    pwm.Set(false);
    pwm.Dispose();
}

Parts List:
MOSFET breakout –http://www.sparkfun.com/products/10256
FEZ Domino – http://www.ghielectronics.com/catalog/category/30/
LED – http://www.sparkfun.com/products/532
Resistor Kit – http://www.sparkfun.com/products/9258

Advertisements
This entry was posted in C#, FEZ, LED and tagged , , . Bookmark the permalink.