SETSENSOR
Syntax SETSENSOR number type
(SETSENSOR number type datatype)
(SETSENSOR number type datatype slope)
Explanation The RCX robot controller has three inputs which may be connected to different types of sensors. Before using a sensor, it is necessary to define the type of sensor which is attached to the input, as well as the format of the data which the sensor is expected to deliver. The first input is the number of the sensor or a list of sensor numbers. Valid numbers are 1 through 3.

There are four different sensor types. One of these values must be entered as a second input.

SWITCH A switch. Switches may very well deliver analog data, depending on the pressure with which the switch is pressed. The range of the output is between 0 and 1023, depending on the pressure on the switch.
TEMP A temperature sensor.
LIGHT A light sensor. This sensor delivers values between 300 and 800 depending on the amount of light.
ANGLE A rotational sensor that measures the rotation. One full turn corresponds to a value of 16. The value is signed, depending on the direction of the rotation.

The format of the data that the sensor delivers is dependent on another keyword, which may be supplied as an optional, third input:

RAW Deliver raw data. The data is left untransformed.
BOOL The data is converted to 0 if the raw input is below 550, and 1 otherwise. This format is the default for switches.
EDGE The data is counted as the number of transitions from 0 to 1 and from 1 to 0.
PULSE The data is counted as the number of transitions from 1 to 0.
PERCENT The data is converted to a value between 0 and 100. This is the default for light sensors.
C The data is converted to a Celcius degree value. This is useful for temperature sensors.
F The data is converted to a Fahrenheit degree value. This is useful (and the default) for temperature sensors

A last, fourth input determines the slope, which is the value difference between the Boolean levels 0 and 1. Valid numbers are 0 through 31, where small numbers mean a small difference.

Use the RCX.PANEL command to display the RCX panel which displays the contents of all variables, sensors, and timers.

Examples SETSENSOR 1 "TEMP
(Sensor 1 is defined as a temperature sensor)
(SETSENSOR 2 "SWITCH "RAW)
(Sensor 2 is defined as a switch with raw input)
SETSENSOR [1 2] "SWITCH
(Sensors 1 and 2 are defined as a switches)

TopIndex