Original Author Paul Laughton, 2011
Page 196
De Re BASIC!
Proximity
8
As of API 3
Gravity
9
As of API 9 (Gingerbread)
Linear Acceleration
10
As of API 9
Rotation Vector
11
As of API 9
Relative Humidity
12
As of API 14 (Ice Cream Sandwich)
Ambient Temperature
13
As of API 14
Uncalibrated Magnetic Field
14
As of API 18 (Jellybean MR2)
Game Rotation Vector
15
As of API 18
Uncalibrated Gyroscope
16
As of API 18
Significant Motion
17
As of API 18
Step Detector
18
As of API 19 (KitKat)
Step Counter
19
As of API 19
Geomagnetic Rotation Vector
20
As of API 19
Some details about (most) of these sensors can be found at
Not all Android devices have all of these Sensors. Some Android devices may have none of these
sensors. The BASIC! command, sensors.list, can be used to provide an inventory of the sensors available
on a particular device.
Some newer devices may have sensors that are not currently supported by BASIC! Those sensors will be
reported as "Unknown, Type = NN" where NN is the sensor type number.
Sensor Commands
Sensors.list <sensor_array$[]>
Writes information about the sensors available on the Android device into the <sensor_array$[]>
parameter. If the array exists, it is overwritten. Otherwise a new array is created. The result is always a
one-dimensional array.
The array elements contain the names and types of the available sensors. For example, one element
may be "Gyroscope, Type = 4". The following program snippet prints the elements of the sensor list.
SENSORS.LIST sensorarray$[]
ARRAY.LENGTH size, sensorarray$[]
FOR index = 1 TO size
PRINT sensorarray$[ index ]
NEXT index
END
Sensors.open <type_nexp>{:<delay_nexp>}{, <type_nexp>{:<delay_nexp>}, ...}
Opens a list of sensors for reading. The parameter list is the type numbers of the sensors to be opened,
followed optionally by a colon (':') and a number (0, 1, 2, or 3) that specifies the delay in sampling the
sensor. 3 is the default (slowest).