ROBOTC.net forums
http://www.robotc.net/forums/

Configuring Sensor Within Program
http://www.robotc.net/forums/viewtopic.php?f=41&t=4292
Page 1 of 1

Author:  DiMastero [ Sun Feb 26, 2012 4:19 pm ]
Post subject:  Configuring Sensor Within Program

Is there a way to configure a sensor from within the program, according to user input? I've tried it using
Code:
SensorType[sensor] = sensorHiTechnicMagnetic
But the sensor is still configured the way I originally initialized it (as a sensorNone), and it gives me an error saying that variable "sensor" was never defined, while, at the start of the program, I configured it using this
Code:
#pragma config(Sensor, S1,     sensor,         sensorNone)
If it's impossible to configure within the program, is there any way to detect what sensor is connected to a given port? (I think it'd be possible with I2C, for digital sensors at least, but I'm just wondering if there is an easier way)

Thanks!

Author:  NeXT-Generation [ Sun Feb 26, 2012 4:22 pm ]
Post subject:  Re: Configuring Sensor Within Program

DiMastero wrote:
Is there a way to configure a sensor from within the program, according to user input? I've tried it using
Code:
SensorType[sensor] = sensorHiTechnicMagnetic
But the sensor is still configured the way I originally initialized it (as a touch sensor)

If that's impossible, is there any way to detect what sensor is connected to a given port? (I think it'd be possible with I2C, for digital sensors at least, but I'm just wondering if there is an easier way)

Thanks!


Is this what your looking for?

Code:
SetSensorType(tSensorsLink, SensorType);

Author:  DiMastero [ Sun Feb 26, 2012 4:30 pm ]
Post subject:  Re: Configuring Sensor Within Program

Yup, that's it. Thanks!

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/