|
|
| Author |
Message |
victorf
Joined: 01 Jan 2006
Posts: 342
Location: Schenectady, New York
|
|
Posted: 05 January 2006, 11:38 AM Post subject: Connecting LEDs and Pin configuration |
|
|
I would like to connect a LED to a ZX on a Port C pin. What is the perferred method to do this.
Also, I guess I do not understand the what the pin configuration mode zxInputTriState and zxInputPullup mean. Could someone characterize these for me?
Any enlightenment will be appreciated
Vic |
|
| Back to top |
|
 |
spamiam
Joined: 13 Nov 2005
Posts: 664
|
|
Posted: 05 January 2006, 21:15 PM Post subject: Re: Connecting LEDs and Pin configuration |
|
|
| victorf wrote: | I would like to connect a LED to a ZX on a Port C pin. What is the perferred method to do this.
Also, I guess I do not understand the what the pin configuration mode zxInputTriState and zxInputPullup mean. Could someone characterize these for me?
Any enlightenment will be appreciated
Vic |
Well, first: remember that you have a 20mA limit on the current through any one pin. This means that you need a minimum of 250 ohms total resistance for the pin. This is enought to drve most standard LEDs to a very bright light. Many require much less. I would use 470 ohms or more, maybe 1000 ohms.
zxInputTristate means that the pin is being used for input, and is set to a high resistance (no pull-up). zxInputPullup means that the pin is set for input, and also has activated a weak pullup resistor. I think that the pullup is 100K ohms to +5volts. This is enough to eliminate noise on a floating pin, but may not be enough for the circuit connected to the pin. Usually, if you need a pullup, then it is best to add that yourself.
To drive an LED, you would need to set the pin to "output", then it will light up if you have the LED grounded and set the pin to "high". The alternative is to have the LED attached to +5, and then setting the pin "low" will make the LED light.
If you have the pin set to input-pullup, then you might get a LED to light up weakly if it is attached to ground.
-Tony |
|
| Back to top |
|
 |
spamiam
Joined: 13 Nov 2005
Posts: 664
|
|
Posted: 05 January 2006, 21:20 PM Post subject: Re: Connecting LEDs and Pin configuration |
|
|
| victorf wrote: | I would like to connect a LED to a ZX on a Port C pin. What is the perferred method to do this.
Vic |
I fogot the "preferred" part of the question. I seem to remember that the AVR microcontrollers are better at sinking than sourcing. So, if this is true, the best method is "backwards" (at least to me). Setting the pin to "zxOutputLow" to make the LED light up is preferred to the other way around.
PIN---1Kohm---LED---+5v
-Tony |
|
| Back to top |
|
 |
|