Python Forum

Full Version: Pulling an ADC value and using it
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I am typing this from a cellphone so please bear with me. But my issue here is I am trying to read an ADC voltage value using an ADS1x15 ADC converter and then store the values as a variable in order to plug that value into an equation. An example script can be seen below:

ADC_Value = adc.read_adc_difference(0, gain=GAIN)
x_Input = (ADC_Value - 68)*(3/24432)
print(ADC_Value)
print(x_Input)

I am unsure as to what Im missing. I do not get any syntax errors only a value of 0 for my x_Input variable every time it prints. I am working on making a PLC to control an industrial fan and this is my first exposure to programming so please have mercy. 

Thank you,
The Hopeful Noob
To help you we need more of the code. We need the code for
adc()
in
adc.read_adc_difference()
.
What version of Python are you using? If you're using 2.x, you need to change one of the values in your division to a float (add '.0' on the end).
That was it. How embarassing haha