# Sensors

Real-time values that comes from the robot's sensors. For example, "if accelerometer z-axis > 3G's, then set LED's to green."

### Accelerometer

Motion acceleration along a given axis, in g's.`getAcceleration().x`

is the left-to-right acceleration, from -8 to 8 g's.

`getAcceleration().y`

is the forward-to-back acceleration, from of -8 to 8 g's.

`getAcceleration().z`

is the up-and-down acceleration, from -8 to 8 g's.

`Math.sqrt((getAcceleration().x ** 2) + (getAcceleration().y ** 2) + (getAcceleration().z ** 2))`

is the combined vector acceleration of all 3 axes, from 0 to 14 g's.

`getVerticalAcceleration`

is the upward or downward acceleration regardless of the robot's orientation, from -8 to 8 g's.

### Orientation

The tilt angle along a given axis measured by the Gyroscope, in degrees.`getOrientation().pitch`

is the forward or backward tilt angle, from -180° to 180°.

`getOrientation().roll`

is left or right tilt angle, from -90° to 90°.

`getOrientation().yaw`

is the spin (twist) angle, from -180° to 180°.

### Gyroscope

The rate of rotation around a given axis, from -2,000° to 2,000° per second.`getGyroscope().pitch`

is the rate of forward or backward spin, from -2,000° to 2,000° per second.

`getGyroscope().roll`

is the rate of left or right spin, from -2,000° to 2,000° per second.

`getGyroscope().yaw`

is the rate of sideways spin, from -2,000° to 2,000° per second.

### Velocity

The velocity along a given axis measured by the motor encoders, in centimeters per second.`getVelocity().x`

is the right (+) or left (-) velocity, in centimeters per second.

`getVelocity().y`

is the forward (+) or back (-) velocity, in centimeters per second.

`Math.sqrt((getVelocity().x ** 2) + (getVelocity().y ** 2))`

is the combined vector velocity of both axes which will always be a positive value, in centimeters per second.

### Location

The distance from the origin of the program start, in centimeters. This is not the distance traveled during the program, it is the offset from the origin.`getLocation().x`

is the right (+) or left (-) distance from the origin of the program start, in centimeters.

`getLocation().y`

is the forward (+) or backward (-) distance from the origin of the program start, in centimeters.

`Math.sqrt((getLocation().x ** 2) + (getLocation().y ** 2))`

is the total distance from the origin of the program start, which will always be a positive value, in centimeters.

### Distance

`getDistance()`

is the total distance traveled in the program, in centimeters.
### Speed

`getSpeed()`

is the current target speed of the robot, from -255 to 255, where positive is forward, negative is backward, and 0 is stopped.
### Heading

`getHeading()`

is the target directional angle, in degrees. Assuming you aim the robot with the blue tail light facing you, then 0° heading is forward, 90° is right, 180° is backward, and 270° is left.
### Main LED

`getMainLed()`

is the RGB color of the main LEDs, from 0 to 255 for each color channel.
`getMainLed().r`

is the red channel, from 0 - 255.

`getMainLed().g`

is the green channel, from 0 - 255.

`getMainLed().b`

is the blue channel, from 0 - 255.

### Back LED

`getBackLed()`

is the brightness of the back LED, from 0 to 255.
### Time Elapsed

`getElapsedTime()`

is the amount of time that the program has run for, in seconds. For example, you could use `getElapsedTime()`

to swap between forward and backward movements every 4s in an ocean buoy animation using:

```
var lastTime = 0;
var loopCount = 0;
async function startProgram() {
setBackLed(255);
for (var _i1 = 0; _i1 < 4; _i1++) {
await Sound.Water.Waves.play(false);
if ((loopCount % 2) === 1) {
while (!(((getElapsedTime() - lastTime) >= 4))) {
setMainLed({ r: 11, g: 255, b: 0 });
await rawMotor(1000, 1000, 0.4);
setMainLed({ r: 0, g: 0, b: 0 });
await delay(0.5);
}
lastTime = getElapsedTime();
} else {
while (!(((getElapsedTime() - lastTime) >= 4))) {
setMainLed({ r: 255, g: 41, b: 16 });
await rawMotor(-1000, -1000, 0.4);
setMainLed({ r: 0, g: 0, b: 0 });
await delay(0.5);
}
lastTime = getElapsedTime();
}
loopCount = (loopCount + 1);
await delay(0.025);
}
}
```

## R2-D2 & R2-Q5 LEDs

### Front PSI LED

`getFrontPsiLed()`

is the RGB color of the Front Process Status Indicator (PSI) LED.
### Back PSI LED

`getBackPsiLed()`

is the RGB color of the Back Process Status Indicator (PSI) LED.
### Dome LEDs

`getDomeLeds()`

is the brightness of the Dome LEDs, from 0 to 15.
### Holo Projector LED

`getHoloProjectorLed()`

is the brightness of the Holographic Projector LED, from 0 to 255.
### Logic Display LEDs

`getLogicDisplayLeds()`

is the brightness of the white Logic Display LEDs, from 0 to 255.