Python Forum
Pulling an ADC value and using it
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pulling an ADC value and using it
#1
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
Reply
#2
To help you we need more of the code. We need the code for
adc()
in
adc.read_adc_difference()
.
Reply
#3
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).
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#4
That was it. How embarassing haha
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pulling Specifics Words/Numbers from String bigpapa 2 723 May-01-2023, 07:22 PM
Last Post: bigpapa
  Having trouble installing scikit-learn via VSC and pulling my hair out pythonturtle 1 716 Feb-07-2023, 02:23 AM
Last Post: Larz60+
  (Python) Pulling data from UA Google Analytics with more than 100k rows into csv. Stockers 0 1,170 Dec-19-2022, 11:11 PM
Last Post: Stockers
  Pulling username from Tuple pajd 21 3,223 Oct-07-2022, 01:33 PM
Last Post: pajd
  pulling multiple lines from a txt IceJJFish69 3 2,522 Apr-26-2021, 05:56 PM
Last Post: snippsat
  Pulling Information Out of Dictionary Griever 4 2,822 Aug-12-2020, 02:34 PM
Last Post: Griever
  Pulling & Reading Date from UDF that Compare it to Live Data firebird 4 2,705 Jul-20-2019, 09:30 AM
Last Post: snippsat
  Pulling data from Sharepoint list gandiswapna0388 1 2,562 Jul-17-2019, 08:35 AM
Last Post: perfringo
  Need help pulling bios serial # or mac Ad cibb 2 2,847 Mar-16-2018, 01:59 PM
Last Post: cibb
  String Pulling pdatt794 1 2,724 Oct-23-2017, 08:18 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020