Jump to content
  • Advertisement
Sign in to follow this  
CProgrammer

simple microcontroller question

This topic is 5477 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well im trying to use a microcontroller to light up a LED. I tried connecting one end of the LED to the GND and the other to my first digital outlet. After turning the outlet on nothing happened. Im fairly new to this whole thing and just want to know how to light up a LED using a digital output(perhaps do I need to put a batterie in row or..). By the way he digital output emmits 5V. Thanks in advance for any help. -CProgrammer

Share this post


Link to post
Share on other sites
Advertisement
LEDs are directional, turn it around and see what happens. If that doesn't work, wire it directly to the supply, with a 180 Ohm resistor and see if it lights.

Share this post


Link to post
Share on other sites
I tried turning around. My problem is that I just dont know how I would attach it. One side into digital out and the other into GND? Is that correct? or how?
The thing is Im not to familiar with micorcontrollers and how the electricity flows with them.

-CProgrammer

Share this post


Link to post
Share on other sites
It should be enough to connect the LED to GND and the micrcontrollers digital out.
In my experience from school I can think of some things:
1/ The LED requires more than 5V
2/ The microcontroller can't supply enough current
3/ The digital out's isn't digital outs at all, with the PIC's I've been using there's a possibility to choose in, out or high-z.
4/ The LED is broken ;)

Hope I've helped.

Share this post


Link to post
Share on other sites
LED's shouldn't require more than 5v in most cases unless you're in a rush to destroy one. I'd say 3 is the most likely option from Mutare's list, what type of microcontroller are you using?

Share this post


Link to post
Share on other sites
ALWAYS use a resistor, say 220-1K ohms or so - that should be plenty of current to make it light up visibly. Odds are you've burned out the port and/or the LED. It doesn't take much; a lot of microcontroller ports can only safely put out a few tens of mA at most.

Share this post


Link to post
Share on other sites
Quote:
2/ The microcontroller can't supply enough current

This one is most likely the problem. Use a resistor as uavfun said. This way the microcontroller sets the voltage but doesn't need to supply the current (it gets drawn down through the resistor).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You definitely need a resistor, as diodes need to be driven at a constant current rather than a constant voltage. Say 10mA current, and voltage drop of 1.5v across the diode, gives you a resistor value of 3.5v / 0.01A = 350 ohms.

Also, double check that you're setting the IO pin to be an output, as Mutare says. If it isn't you can't draw much current from it. :P

Share this post


Link to post
Share on other sites
Thanks for the help everybody. I think the outs are working fine since I can attach an out to an 'in' and something arrives at the 'in' port.
The resistor is probably the thing. Ill get one as soon as possible and try it out.
Thanks again.

-CProgrammer

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!