A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
Just for reference for "future people" that may stumble across this page:
For a touch sensor, this is 0 (released) or 1 (true), I believe. For the light sensor, it's 0% to a 100%. For the US sensor, it's simply in centimeters. The sound sensor is in dB.
Commit to LEGO Mindstorms Robotics Stack Exchange: bit.ly/MindstormsSE
Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
When you set up a port to be used for a specific sensor, it not only does what it needs to electrically, but it also changes the way it reads it. For analog sensors, it read them in RAW (0-1023), and then it scales them to the range specified by the sensor type and/or mode.
If you specify the sensor as a touch sensor, any RAW value below ~450 (IIRC) is returned as a 1, and anything over that is a 0. If it is a light sensor, it scales it to 0-100%, but I'm not sure if it is linear or over the full RAW range.
Even when the type and mode is specified, you can still read the RAW value.
thank you!
the Sensor definitions of the Lego fw are really confusing me: too many keywords which do anything obscured and odd or weird and unpredictable.
now is there a way to use SetSensor or SetSensorType or SetSensorMode to do the same as SensorNormalized ?
mattallen37 wrote:If you specify the sensor as a touch sensor, any RAW value below ~450 (IIRC) is returned as a 1, and anything over that is a 0. If it is a light sensor, it scales it to 0-100%, but I'm not sure if it is linear or over the full RAW range.
doc-helmut wrote:thank you!
the Sensor definitions of the Lego fw are really confusing me: too many keywords which do anything obscured and odd or weird and unpredictable.
now is there a way to use SetSensor or SetSensorType or SetSensorMode to do the same as SensorNormalized ?
I know what you mean, and I am still somewhat confused by all the options as well. instead of using all these special things, I use RAW for almost everything (except digital sensors or the RCX rotation sensor).
AFAIK SensorNormalized is the same as using "SENSOR_1", or "Sensor(S1)". Setting the type and/or mode has a direct effect on it.
For analog sensors, I recommend using SensorRaw(). I haven't tried this yet, but you should try using an inline operation (I don't remember what it's called), like this: "(SensorRaw(S1)<700?1:0)" to read the boolean state of the touch sensor. You should be able to use very simple math to work for any of the analog sensors from the RAW values.