Calculating resistor values for a parallel circuit

Not sure how to explain this, so hopefully it makes sense ... I suspect this is probably pretty easy for someone that knows what they're doing.

I'd like to build a simple circuit involving two resistors and two switches ... this part is no issue. I want to attach one side of each resistor to a single analog pin on an arduino (probably a mini), then each resistor to a switch, then each switch to ground creating parallel circuits from the one pin.

The challenge is that I want to size the resistors so that an analog read of the pin (when pulled up) will return values in 4 distinct ranges ...

  • Both S1 and S2 are open
  • Only S1 is closed
  • Only S2 is closed
  • Both S1 and S2 are closed

The other consideration is that I'd like the ranges to be large enough to allow for a little bit of tolerance in the wire, connections, and the resistors themselves as I'd like to repeat this a bunch of times (all virtually identical) but want the return values to be somewhat predictable so that no adjustments need to be made per pin (the analog read for a scenario might be +/- 100, but that shouldn't overlap the other possibilities).

Any insight on how to calculate what resistor values to use for this would be greatly appreciated.

Thanks

Lookup the R 2R ladder circuit on google. That is what you want. Use 1K and 2K resistors.

More serial than parallel:

I think I was going at it wrong .. this is exactly what I needed. Thanks for you help!

I'd like to build a simple circuit involving two resistors and two switches ... this part is no issue. I want to attach one side of each resistor to a single analog pin on an arduino (probably a mini), then each resistor to a switch, then each switch to ground creating parallel circuits from the one pin.

The circuit you describe has the pin either at ground potential or floating if
both switches are open. Remember an input pin carries no current.

Adding another resistor from the pin to Vcc would create a voltage divider setup,
which would work if the two switch resistors were different values.

No problem.