Hello everyone – I'm trying to understand and use Ohms law using the simple circuit below.
Basically, there are three push buttons, if S1 is pushed, the Arduino should measure a full voltage on pin 1 – and it does, I get a reading of 1020 (pretty close to 1024).
With S2 closed, I get a reading (from analogRead() of about 510 (509/510) on Pin 1. So, if think about this – each reading from Analogread() on pin 1 is equal to about 5/1024 or .0049 ma. Does that tell me that the voltage reading on Pin 1 is 510*.0049 or about 2.5v ?
With S3 closed, I get a reading of 339 – and with that same calculation I would get 339*.0049 or 1.66v
So I'm not sure how the math would work to describe this via Ohm's law. Can anybody help me ? Or is my logic all wrong ?
Sorry - having trouble posting an image. Basically the circuit is a connection to pin 1 (for the analogread() ) and a switch to connect +5v directly to Pin 1. Another switch (s2) to connect to pin 1 via a 100 ohm resister. And a third switch that connects to pin via the first 100 ohm resister and an additional 100 ohm. So s1 = no resistance, s2=100 ohm and s3=200 ohms
The readings will depend entirely on how the buttons are wired. The impedence of an analog pin is close to infinite so Ohms law really only works on the external resistances of your circuit.
You need them wiring as a voltage divider, not in series with the pin, 100 ohms is neither here nor there in relation to the effective resistance of an analogue input .
Your answers are basically correct. The logic and laws to use are pretty straightforward and you have wired a valid voltage divider type circuit.
First depending on if only one switch is pushed at a time you are completing a circuit between ground and +5vdc, with the grounded 100 ohm resistor always in the circuit. You are adding additional 100 ohm resistor(s) in series when you push either of the other two switches.
So first pick a switch to press and determine how many 100 ohm resistors are being placed in series. In series circuits the resistors add to establish a total circuit resistance. So S1 = 100 ohms, S2 = 200 ohms, and S3 = 300 ohms.
Once that is known you can calculate the total circuit current being drawn by the resistor(s) by doing I (in amps) = voltage (5vdc) / R (total circuit resistance).
Now you know what the circuit current is, depending on which switch is being pressed, you can calculate the voltage drop across the resistor wired to ground as that is the resistor the analog input pin is measuring. So the applied voltage to the analog pin is E (voltage) = current (from prior calc in amps) X 100 ohms.
Try that on paper and see if it doesn't make sense to you.