# How many resistors do I need for an 8 switch DIP switch block?

I was thinking of giving each switch it's own pull-up resistor, but this seems like it would be expensive and a little bit of overkill. But using just one pull-up for the entire block seems like it might overload the resistor (unless I just use a big one).

Are there any guidelines in this situation?

SMD resistors are as cheap as dirt. Especially if you would buy full roll of let's say 10k ones (i.e. something widely-used, so that you could use in multiple projects). It's hard to overload pull-up resistors, as they can dissipate 0.125W usually.

There are also 4 and 8 resistors in 1 package, this will be even cheaper if you are on large scale.

You cannot use single resistor for multiple wires - as they will be shorted (or you will need diodes :-D )

• Oh, duh about your last comment, I didn't even think about that! Thanks! – samoz Jan 20 '11 at 15:05
• @samoz: That will turn your switches into a logic gate (e.g. NOR or similar depending on how you have it wired), and you won't be able to get 8 independent signals out of them. – Nick T Jan 20 '11 at 16:24
• It's not because the allowable dissipation that it's hard to overload pull-up resistors, but because they usually have high resistance values, like 10 kohm. 5 V in 10 kohm is 2.5 mW. (Besides, 0603 resistors are 100 mW, not 125) – stevenvh Jun 7 '11 at 17:52

Depending on the application, you may have built-in pull-up resistors. AVRs like the ATmega168 and '328 do…

• Are there any DIP switches with built-in resistors? I'm pretty sure they exist, but my google-fu has failed me. – samoz Jan 20 '11 at 15:18
• Not DIP, AFAIK. Some BCD thumbwheel switches have them, IIRC. – Leon Heller Jan 20 '11 at 15:37

If your micro has no pullups, another approach is to common one side of all switches, connect to an input with a pullup, and connect each of the switches to other IO pins. The latter pins are all tri-stated except one at a time, which is pulled low to read the state of its switch on the input pin.

If you connect all your switches to the single resistor all your switches will be parallel, and you'll have only 1 output instead of 8. In fact this is a NOR gate: if at least one switch is closed the output will go low, if all switches are open the output will be high. This may have its application, but it's not the functionality you want.

You need a pullup resistor per switch.

Like BarsMonster says resistors are cheap (not only the SMDs). Don't buy a single part, a single 1/4W carbon film resistor costs 8 cent at Digikey, at set of 100 costs 2.2 cent per resistor. Have a few standard values at hand, like 1k$\Omega$ (typical for a transistor's base resistor) and 10k$\Omega$ (typical for pullup).