Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3989

General • Re: Pull-ups or pull-downs?

$
0
0
Your circuit is not going to work well.

There is no current limiting resistor inside the Pico. There is a small amount of resistance within the pin drive cell of the RP2040 (and you can adjust it with the drive strength setting), but you should not use it to limit the current through a LED - always use an external resistor for that. However, for short-duration experiments you will probably get away with even driving a pin into a short circuit; your LED is not so bad as that, but still not recommended.

More of a problem with your circuit is when you try to use the pin as an input. With the switch open, the input is satisfactorily pulled down to zero by R1. With the switch closed, the pin will be at some intermediate voltage - with the pin high impedance, you have a circuit with two LEDs and a resistor in series and the pin measuring the voltage in the middle of it - so it's probably about 2V, if indeed any current is flowing at all (depending on the exact LEDs you choose, their forward voltage may be too high to support two of them in series from a 3.3V supply).

If you want to have two LEDs for 'driven high' and 'driven low', then you can attach both of them to the pin (each with their own series resistor), one to 3V3 and the other to GND. That's a useful configuration for output, where one will light brightly when the output is high, the other will light brightly when the output is low, and when the pin is switched to high-impedance input they will both be off (or maybe both very dim, again depending on the Vf). But that arrangement leaves the pin at a middle voltage when undriven, neither high nor low and needing two switches if you want to manually set the input states.

If you want to more accurately simulate what an 8-bit era bus was like, you could have just one LED (with series resistor) between the pad and 3V3, an additional pull-up resistor to ensure the input actually reaches 3V3 when undriven (you could enable the on-chip pull-up resistor for this rather than fitting an actual resistor) and then your switch shorting the pin to GND. This would give the pin reading '1' when undriven, and your button driving it to '0' when pressed. You could put a small series resistor with the switch (say 100R) if you want to be completely safe against pressing the switch when software is driving the output.

Statistics: Posted by arg001 — Thu Oct 10, 2024 7:50 am



Viewing all articles
Browse latest Browse all 3989

Trending Articles