CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

How to drive LED on PIC24FJ128GB110 ?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
boomsomehand



Joined: 15 Jan 2012
Posts: 1

View user's profile Send private message

How to drive LED on PIC24FJ128GB110 ?
PostPosted: Sun Jan 15, 2012 12:50 pm     Reply with quote

I need programming to drive LED on PORT A0.
Thanks !
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Sun Jan 15, 2012 4:53 pm     Reply with quote

Hi,

Is this a trick question????

At the top of your program (you have a program???) do this:

Code:

#define LED Pin_A0


Inside your Main routine, do this:

Code:

output_high(LED);


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

View user's profile Send private message

PostPosted: Sun Jan 15, 2012 5:44 pm     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Sun Jan 15, 2012 8:03 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group