After some research and asking around I found a solution. The law of resistors in a parallel circuit is 1/R = 1/R_{1} + 1/R_{2}. R is the total resistance and R_{1} and R_{2} are the resistances of the resistors. If you press the buttons of the 220 Ohm and the 1 MOhm resistors for example not a lot would happen because the total resistance would be 219,95 Ohm.

You've almost got it xinatron; nothing wrong in that but you've forgotten the pull-down resistor of 10K-Ohms and, not sure if you have this correct in your head or not but, the Arduino isn't measuring resistance (Ohms) or current (Amps/Amperes); the Arduino is measuring Voltage. (

_{Specifically the Arduino is measuring the difference in voltage between the sensing pin, A0, and the Arduino's reference. More on that here, be careful and read the whole thing or you might damage your Arduino.})

So what we're dealing with in Project 7 isn't just a parallel circuit, it's what's known as a Combination Circuit or a Series Parallel Circuit. The short explination on how you calculate values for a series parallel circuit is you first simplify all parallel parts into logically-discreet parts, so that you can consider your entire circuit as a simple series circuit. You simplify the parallel parts with that formula you included:

1/R_{T}=1/R_{1}+1/R_{2}+...1/R_{n}

Now in the resistor ladder circuit we've built in Project 7 what we really want to know is how much voltage has the parallel part dropped (consumed); if we know that we will know how much voltage the Arduino will be measuring. Consult Ohm's Law and do the following:

- Simplify the circuit.
- Calculate the total resistance of the circuit.
- Calculate the total current of the circuit
- Calculate the voltage drop across you simplified parallel circuit.
- Subtract the voltage consumed by the parallel circuit from the total. Now you know how much voltage the Arduino will measure.

Case 1:Since our circuit has 4 switches this is a bit more complicated. There are 16 different possible parallel circuits (look at the switches as 4 bits in binary or take my word for it;). I'm only going to demonstrate 2 (well 3). Lets consider pushing just switch #2. Switch 2 will cause current to flow through a 220 Ohm resistor. We'll have a simple series circuit in this case.

+5V---|SWITCH|---|220 Ohm|---|Sensor|---|10K Ohm|---Ground

How much voltage will the Arduino measure at the Sensor? Lets find out:

- Some rules for series circuits: V=IR; Resistance adds; Current is the same; Voltage adds to total.
- 220 Ohm + 10K Ohm = 10,220 Ohms
- 5V = I x 10,220
- 5V/10,220 = I
- I = 0.000489 == 0.489 mA == 489 uA
- Current is the same for the whole of the series circuit, so:
- I
_{R1} = 0.489mA - V
_{R1} = 0.428mA x 220 Ohms - V
_{R1} = 0.108 V

With R1 (the circuit's second resistor we brought into play by pressing the button) dropping 0.108V that means that the Arduino's sensor (pin A0) will see 4.892V. We can estimate what the value of analogRead(A0) will be if we know that. analogRead will return a value from 0 to 1023, that's 1024 different possibilities. It's measuring in a 5V circuit. So 5V/1024-levels = 4.88 mV per 1 level. So if A0 is seeing 4.892V/4.88mV = 1002(.46). analogRead(A0) should be about 1002.

Case 2:How about 2 switches? OK! Lets use the second and third switches which have resistors of 220 Ohm and 10K Ohm respectively. Remember, these switches are in parallel.

+5V-\--[Switch 1|---|220 Ohm|--/-|Sensor|---Ground

_____\-[Switch 2|---|10K Ohm|-/___________________

- Simplify the parallel part of the circuit into a logically-discreet component.

- Some rules for parallel circuits: V=IR; 1/R
_{T}=1/R_{1}+1/R_{2}...1/R_{n}; Voltage is the same across branches; Currents add to the total (2A go into 2 branches of equal resistance? Each branch has 1A going through it.) - 1/R
_{T}=1/220 + 1/10,000. - 1/R
_{T}=0.00464545... - R
_{T}=215.264

- OK! Now we have (what we can think of as) a simple series circuit again! Same as above:

- Series' R
_{T} = 215.264 + 10,000 (Parallel + that 10K pull-down resistor) - R
_{T}=10215.264 - 5V = I x 10215.264
- 5V / 10215.264 = I
- I = .00048946 == .48946mA == 489.46uA

- Therefor the voltage drop against our parallel circuit is:

- V = 489.46uA x 215.264 Ohms
- V = 0.1054 == 105.4mV

- Therefor the Arduino will sense 4.8946V! Turned into analogRead(A0) output it would be: 1002(.99)

And yeah, that's the same analogRead output as with just the 220 ohm resistor... I was quite unimpressed with this particular project. They hint to how powerful the resistor ladder could be but don't demonstrate it at all well. Perhaps that was on purpose... anyway, onto Case 3.

Case 3:You push that first switch that doesn't have a resistor on it + switch 2 with a 220 Ohm resistor. This case is super simple. The two switches make up a parallel circuit, one branch has no (relavent) resistance and the other branch has 220 Ohms of resistance. How do we calculate the drop across the parallel part in this situation? EASY: The first branch has no resistance in it, we call that a SHORT! In this situation ALL (so far as we care) of the electricity will flow through the short; no electricity will bother flowing through the resistor on the other branch. Remember: Electricity will always take the EASIEST path to ground. So the 220 Ohm resistor is compleatly bypassed. Now if you're wondering about above when it was a 220 Ohm and a 10K Ohm resistor, why didn't it all flow through the 220 Ohm resistor? Because there was some resistance in both paths. MOST of the electricity went through the 220 Ohm resistor, but some went through the 10K Ohm resistor. Specifically the 220's current was 0.479mA and the 10K's current was 0.01054mA. (I used the voltage drop of the parallel part, that voltage is applied to all branches of the parallel part equally. So it was 0.1054/220=I

_{R1} and 0.1054/10K=I

_{R2}).

So yeah, like I said, I was severely disapointed in this project in the Arduino book. It was obvious to me, and I think it was mentioned, that it would be possible to build a resistor ladder such that you could not only tell each button appart; but you could also tell all button combinations appart. So I built a circuit with that goal in mind: to be able to read all 16 possible button combinations. Now mind you I've had electronic classes before and I have parts from them, that's where these resistors came from. You should be able to acomplish this with the kit's 220, 540, 1K, & 4.7K Ohm resistors; but I haven't run the math. First thing I had to do was eliminate the short on switch 1 if I wanted to be able to read button combinations including button 1; see the previous paragraph for why. Next I gave each switch these resistors:

- Switch 1 a 1K Ohm resistor
- Switch 2 a 2.2K Ohm resistor
- Switch 3 a 4.7K Ohm resistor
- Switch 4 a 8.2K Ohm resistor

All I was trying to do was double the resistance for each step in the resistor ladder. Then I did a bunch of math, exacly the same as above in case 2, and found out that YES all possible combinations resulted in more that 4.88mV of difference at the sensor than any other combination of buttons.

AND THEN ... I spent some hours writing this code, it took some help (thanks weekend!) and it's probably a bit advanced for most people reading this, but I commented it up so hopefully people can understand it.

https://bpaste.net/show/01709bbb39f9 << That's the code, this post is too long if I put it in here; besides, this way you get pretty colours.

Then I went to find somebody to tell my story to. Enjoy!