After watching PW's tutorial 10, I set up the following sketch and wanted to measure the voltages of both resistors (horizontal 330 ohm and vertical 220 ohm):
const int READ_PIN = A3;
void setup() {
// put your setup code here, to run once:
pinMode(READ_PIN, INPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int realVal = analogRead(A3);
float actualVal = realVal / 1023.0 * 5.0;
Serial.println(realVal);
delay(1000);
}
However, in the sketch, I can only measure the voltage passing through the 330-ohm resistor, but in the video PW measured that of both resistors. So I was wondering if you could give me a hint of what I should do and where I did do wrong?
Thank you! (Also I am new to Fritzing, so the image may not be the best...)
Current passes through. Voltage is measured between two points.
You know the ground is 0V, and you are assuming the VCC is 5V to calculate V1= realVal / 1023.0 * 5.0, so the voltage across the second resistor is V2=5-V1.
Yes, sorry for not asking more clear: I wanted to know with this setup, is it possible to measure the voltage of vertical resistor directly with only moving the wires (i.e., keep the resistors untouched)?
The resistance of the two resistors in series is 330 + 220 = 550. If 5volts is applied across 550 Ohms, the current flowing will be 5V / 550Ω = 0.00909090909091 Amps. That current flowing through 220Ω will build a voltage of 220Ω * 0.00909090909091 Amps = 2V. The same current flowing through 330Ω, it will build 3V.