Reading from a sensor without event handler

Supporting Visual Studio on Windows
Post Reply
taylornicole906
Fresh meat
Posts: 1
Joined: Thu Oct 22, 2020 2:37 pm
Contact:

Reading from a sensor without event handler

Post 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.
User avatar
mparadis
Site Admin
Posts: 959
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: Reading from a sensor without event handler

Post 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);
		}
	}
}
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests