Sensor Object

Purpose:

Gives access to the cell phones internal sensors.

Syntax:

sensor.methodname where methodname is one of the following

values
register
unregister
list
 

Comments:

Example:

// from command line dump sensor list to screen

sensor.list

Use the above command from a terminal window to see whats sensors your device has.

// list sensors into string array ss

sensor.list ss

p ss // see below

After the sensor.list ss command, the ss string array will contain the names of the available sensors.  "ss" could be any name other than a reserved word.

This command will register Goldfish 3-axis Accelerometer. After registering the sensor, you can access its current value.
sensor.register ss[0]
To unregister the sensor use the unregister method.
sensor.unregister ss[0]
You should only register the sensors you need, and when you are done with the sensor, you should unregister it to save battery life.
To access the sensors value, use the values method as shown below
sen1 = ss[0]
xx = sensor.values(0,sen1)
Some sensors have multiple values, in the example above we are accessing the first value, index 0
xx2 = sensor.values(1,sen1)
Here we accessed the second value.