It's well known to not have floating pins as inputs to a microcontroller, and pull-up or pull-down resistors should be used.
My question is whether a diode attached to ground would accomplish the same thing. I know that a diode with current flowing through it has a ~2V drop across it.
Will it be a robust pull-down in the attached circuit when the switch is open?
No. I'd suggest moving R2 to the top of R1 and then use another resistor to pull the pin low. The other problem you have with your circuit is that the switch won't pull the input pin all the way high. It'll pull it up to roughly 4v which will likely be enough for the PIC to register it as being high, but I don't like it.
It's well known to not have floating pins as inputs to a microcontroller, and pull-up or pull-down resistors should be used.
My question is whether a diode attached to ground would accomplish the same thing. I know that a diode with current flowing through it has a ~2V drop across it.
Will it be a robust pull-down in the attached circuit when the switch is open?
My question is whether a diode attached to ground would accomplish the same thing. I know that a diode with current flowing through it has a ~2V drop across it.
Will it be a robust pull-down in the attached circuit when the switch is open?
LEDs do not conduct electricity once the voltage gets below 1.2 volts or so. That is just about the threshold voltage for PIC inputs, so it will act as a floating input. Also, LEDS generate voltage when exposed to light, so the circuit's function will depend on ambient light conditions, which will make things even worse.
Actually, no it's not 'well known' - there's really no problems associated with leaving PIC inputs floating.
If you're wanting to actually use it as an input, then it's obviously important to ensure that both high and low states are accurately defined, and pullup resistors are most commonly used for that purpose.
An LED and its current limiting resistor should work fine as a pull-up or pull-down.
In the circuit below I sample the switches periodically by switching the pins to inputs then I switch them back to outputs to illuminate the LEDs. A switch press does illuminate the LED but in the circuit below each switch press toggles the LED so you can't really tell that the switch is lighting the LED.
Actually, no it's not 'well known' - there's really no problems associated with leaving PIC inputs floating.
If you're wanting to actually use it as an input, then it's obviously important to ensure that both high and low states are accurately defined, and pullup resistors are most commonly used for that purpose.
Really? I thought with the earlier PICs that used TTL digital inputs there was a problem with latchup, and that was part of Microchips decision to start changing all the digital inputs to schmidt triggers in the mid 90's??
I know the PIC schmidt type digital inputs are pretty immune to latchup, you can leave them floating.
Well, I'm not going to argue with you about it, it won't do either of us any good. I will accept what you say as an unsubstantiated fact, but with a grain of salt, and continue setting my pins unused pins to output.
Well, I'm not going to argue with you about it, it won't do either of us any good. I will accept what you say as an unsubstantiated fact, but with a grain of salt, and continue setting my pins unused pins to output.