## Re: [Electronics_101] Re: AVR - Input pin circuit question...

Expand Messages
• ... I m not sure this is necessary. (More below) ... None of this is necessary if we can be sure that the pin in question is only ever going to be an input.
Message 1 of 11 , Mar 27, 2006
• 0 Attachment
On Monday 27 March 2006 05:09 pm, Bob Hyland, PMP wrote:
> I assume from your discussion that you want the LED to be triggered
> at the same time as the input, and that you are not truly trying to
> use it sometimes as an input, and sometimes as an output.
>
> Short answer: Yes, you can use the same line to drive an LED and the
> input.
>
> Longer answer: You need to work through the math to determine the
> exact setup. For instance, what kind of LED? "Standard" LED's drop
> perhaps 1.6 V. So, you need to make sure that your circuit takes
> into account this voltage drop, and that the MPU will recognize the
> reduced/increased input as a valid positive or zero value (depending
> on how you hook it up).

I'm not sure this is necessary. (More below)

> Notice, though, that I said "standard." When it comes to LED's,
> (and point to other sites with LOTS & LOTS of esoteric info on
> LED's). But, that would divert from the question (although it is an
> interesting discussion in its own right).
>
> The way to know how much voltage your LED's will drop is to measure
> it. I have heard many a story where engineers ASSumed (ahem) that
> LED's drop the same voltage as a "standard" (there's that pesky word
> again) diode. Well, some do. Most don't.
>
> So, measure the drop and make sure the the MPU will work reliably
> with that voltage change. Otherwise, you may need to create parralel
> paths so that the MPU see's "0" or "+5V" instead of "1.6" or "3.4"
> or whatever.

None of this is necessary if we can be sure that the pin in question is only
ever going to be an input. If we tie the LED and resistor to ground at one
end, and the other end of that pair to the switch, the junction of those
with the switch can also be tied to the input pin and it's either going to be
at zero volts or at +5, the drop of the LED not being particularly relevant
here. I was trying to say this in my earlier post, perhaps I was less than
clear.

If there's any chance that the LED is going to be an output at any point in
time, some low-value resistor (say a couple of hundred ohms to maybe 1K) can
be connected between the point described and the pin, and will serve to
isolate them from each other if the pin should become an output, but will
likely have no effect for those times when the pin is in an input.

> Another thing to keep in mind: current flow. Many people will have
> an LED draw 20 mA to have it shine nice and bright. Make sure the
> pin can supply and/or sink 20 mA (or whatever you decide to use).

The drive of the pin isn't particularly relevant here either, since it's
being used as an input -- it's the switch that's going to decide whether the
LED is on or off, not the pin that's connected there. Unless I'm seriously
misunderstanding something here...

--
Member of the toughest, meanest, deadliest, most unrelenting -- and
ablest -- form of life in this section of space, a critter that can
be killed but can't be tamed. --Robert A. Heinlein, "The Puppet Masters"
-
Information is more dangerous than cannon to a society ruled by lies. --James
M Dakin
Your message has been successfully submitted and would be delivered to recipients shortly.