Page 1 of 1

Reading from a sensor without event handler

Posted: Thu Oct 22, 2020 2:42 pm
by taylornicole906
Is there a way to get a voltage reading from a sensor outside of using an event handler? The only examples I've seen of reading voltage ratio look like this:

Code: Select all

private void LoadCell_VoltageRatioChange(object sender, Phidget22.Events.VoltageRatioInputVoltageRatioChangeEventArgs e)
        {
            //when the sensor detects a voltage change, it executes this.          
            if (loadCellRatioVoltageChangeArray.Count <= 50)
            {
                loadCellRatioVoltageChangeArray.Add(e.VoltageRatio);                       
            }            
        }
I want to be able to read from the sensor without having the voltage ratio change event happening.

Re: Reading from a sensor without event handler

Posted: Thu Oct 22, 2020 2:45 pm
by mparadis
You can always use the VoltageRatio property, like this:

Code: Select all

using System;
using Phidget22;

class Program {
	static void Main(string[] args) {
		VoltageRatioInput ch = new VoltageRatioInput();
		try {
			ch.Open(Phidget.DefaultTimeout);

			double VoltageRatio = ch.VoltageRatio;

			ch.Close();
		} catch (PhidgetException ex) {
			Console.WriteLine("Failure: " + ex.Message);
		}
	}
}