I want to place a 4-way DIP switch to enable setting the "operation mode" for my Pi project. The GPIO pins will be in "IN" mode with "PullDown" flag enabled.

How do I calculate the value for R??

I wonder if 1K resistor is going to be too much? I read that it is recommended to use at least 1K resistor to protect the GPIO pin from overload.

From what I know the voltage drop is calculated as V=IR, which means if we have 50mA current as produced by 5V rail ( not sure what is the impedance of RPi GPIO in input mode), and 1000 Ohm then the voltage on GPIO PIN is going to be about 4.9 V.

Am I missing something?


  • 1
    \$\begingroup\$ R=0 . With GPIO pull-down enabled. Or you may connect PWR_FLAG to GND and use GPIO pull-ups. PWR_FLAG may not be connected in any way to 5V!! \$\endgroup\$ Sep 18, 2021 at 18:37
  • 1
    \$\begingroup\$ So what are you trying to do? If the DIP switch is open, the IO pin will float, which is invalid unless input has pull-down enabled. When DIP switch is closed, it connects IO pin via resistor to something -what voltage is at top of the resistor? The IO pin only tolerates 3.3V, connecting it to 5V, even via a resistor, would not be good design either. \$\endgroup\$
    – Justme
    Sep 18, 2021 at 18:41
  • \$\begingroup\$ @Justme I am planning to pull-down on the input GPIOs ( updated the post as well ). \$\endgroup\$
    – jdevelop
    Sep 18, 2021 at 18:42
  • \$\begingroup\$ @MarkoBuršič Rignt, I just read that for the input only 3.3V is acceptable, anything higher will damage the circuit. So basically I don't need any resistor whatsoever as soon as I connect the input for DIP to 3.3V on RPi itself? \$\endgroup\$
    – jdevelop
    Sep 18, 2021 at 18:43
  • 1
    \$\begingroup\$ No, the GPIO will be HiZ at startup, so no current will flow. After you will configure it as INPUT and PULL-DOWN, then it will sink 3.3V/Rpulldown. After that you have a valid state that you can read. \$\endgroup\$ Sep 18, 2021 at 18:48

1 Answer 1


In general a typical circuit is to use an internal pull-up and ground the pins via DIP switch.

But since the IO pins can have an internal pull-down, the DIP switch can also be wired to connect to 3.3V supply.

No resistor is needed, but it must be taken care that in no case the pin becomes an output, or if it does, it will push or pull the voltage to the same voltage where the DIP switch common is connected. Perhaps four 1k resistors in series is a good choise so the IO pins are fool-proof and you can't short circuit them accidentally.

  • \$\begingroup\$ Thanks for the tip, much appreciated! I realized that most of my hobby projects were using that pull-up and ground schematic, and yet I was adding the 1K resistor before the ground to limit the current ( just in case of wrong I/O mode set initially when Pi starts). I wander though if I can use a single 1K resistor before DIP common connection? Just to save some space on PCB. \$\endgroup\$
    – jdevelop
    Sep 22, 2021 at 14:14
  • \$\begingroup\$ You can but if one GPIO is output it will override all input pins connected via DIP, and if multiple GPIOS are outputs, they are still shorted together. \$\endgroup\$
    – Justme
    Sep 22, 2021 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.