This is what the circuit looks like:
Vin = 5v
R1 = 330 ohm (Resistance value we're trying to read)
R2 = 10k ohm (Known constant resistance)
The code to achieve this looks like this:
var knownVoltage = 5; var knownResistance = 10000; while(true) { var reading = analogInput.Read(); var voltage = (5 / 1023) * reading; var resistance = knownResistance * ((knownVoltage / voltage) - 1); Debug.Print("Resistance: " + resistance); Thread.Sleep(1000); }
My reading is way off and I'm sure it's because of my logic above. Math is flawed somehow. Does anyone see what I did wrong?
Thanks in advance for any input or advice!
-T