View previous topic :: View next topic |
Author |
Message |
boomsomehand
Joined: 15 Jan 2012 Posts: 1
|
How to drive LED on PIC24FJ128GB110 ? |
Posted: Sun Jan 15, 2012 12:50 pm |
|
|
I need programming to drive LED on PORT A0.
Thanks ! |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Sun Jan 15, 2012 4:53 pm |
|
|
Hi,
Is this a trick question????
At the top of your program (you have a program???) do this:
Inside your Main routine, do this:
Connect the anode of the LED to Pin A0. Connect the cathode of the LED to one end of a 300 ohm resistor (value is not super critical), and connect the other end of the resistor to gnd.
When you run your program the LED should light.
John |
|
|
RoGuE_StreaK
Joined: 02 Feb 2010 Posts: 73
|
|
Posted: Sun Jan 15, 2012 5:44 pm |
|
|
Yes, that's a rather vague question...
What kind of LED? A little standard 20mA job, or a 3Amp Cree? If the former, then yes you can direct-drive from a pin (well, it's rated at 18mA, so anything under that), if the latter (or over 18mA) then you'll need to drive another circuit, essentially using the pin to turn the other circuit on/off, eg with a transistor or via an "enable" pin of an LDO regulator, a constant-current sink, or something like that.
What do you want to do with it? Just blink, fade it, ...? All cases essentially boild down to turning the LED on and off, just depends on how regularly and how fast. ezflyr has shown how to turn the pin on, you can vary timing between on and off to create different brightnesses (look up "PWM"), or you can use the onboard hardware PWM to take care of the timing for you. |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Sun Jan 15, 2012 8:03 pm |
|
|
Well, it just might be a bit more complicated.
Port A0 mustn't be analog and shouldn't be open drain unless you are planning on an external pull up. |
|
|
|