If I set a gpio to be an input could I damage it by directly connecting it to 3.3V?
AFAIK you can't but why do people use a resistor in between?
Sorry if this question is stupid but I could not find any answer to this whatsoever.
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It only takes a minute to sign up.
Sign up to join this communityYou can connect 3V3 to a GPIO set as an input without a problem.
A resistor is often used in series with a GPIO to prevent accidental short circuits. E.g. if the GPIO was accidentally set as a low output then there would be a short-circuit between ground and 3V3 if no resistor was present.
Another reason is if the GPIO is accidentally connected to 5V it might survive if a current limiting resistor was in place. Without the resistor the voltage protection circuity would possibly be overloaded and the GPIO and Pi might be destroyed.
The maximum current you are advised to source or sink through one GPIO is 16 mA with a total maximum of 50 mA for the GPIOs as a whole.
I think its likely that in the specific cases were you are seeing "people use a resistor in between" is that they are using a "pullup" resistor. This is used to set a default value for an input when the real input is not hooked up.