EasyManua.ls Logo

LEGO MINDSTORMS Robots

LEGO MINDSTORMS Robots
226 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Table 4-2. Input Type Constants
Type Constant Sensor Type
SENSOR_TYPE_TOUCH
Touch sensor
SENSOR_TYPE_TEMPERATURE
Temperature sensor
SENSOR_TYPE_LIGHT
Light sensor (powered)
SENSOR_TYPE_ROTATION
Rotation sensor (powered)
SetSensorMode(expression sensor, const mode)
Use this command to set the mode of the given input. While the SetSensorType() command is used to specify the electrical characteristics of the input, the SetSensorMode() command
specifies how the input value should be processed. The modes are listed in Table 4-3.
Table 4-3. Input Mode Constants
Mode Constant Description
SENSOR_MODE_RAW
Raw sensor value from 0 to 1023
SENSOR_MODE_BOOL
Either 1 or 0
SENSOR_MODE_EDGE
Counts transitions from 1 to 0 and vice versa
SENSOR_MODE_PULSE
Counts transitions from 1 to 0
SENSOR_MODE_PERCENT
Percent from 0 to 100
SENSOR_MODE_CELSIUS
Celsius temperature
SENSOR_MODE_FAHRENHEIT
Fahrenheit temperature
SENSOR_MODE_ROTATION
Shaft angle, 16 counts per full revolution
Internally, input values initially have a raw value from 0 to 1023. Raw values are converted to the input values that your program sees by a process that depends on the input mode. Three of the
modes count events: SENSOR_MODE_EDGE, SENSOR_MODE_PULSE, and SENSOR_MODE_ROTATION. The other modes perform a mathematical scaling operation on the raw input value.
For example, if the input mode is SENSOR_MODE_PERCENT, the RCX converts the raw value into a percent according to the equation:

Table of Contents

Related product manuals