RobotC and the Vex Accelerometer

My team has been working on code that uses the Vex Analog Accelerometer v1.0 recently ( and after hours of frustration I thought I’d post on the forum everything we learned from the experience:

  1. The RobotC sample code is completely wrong. I don’t know what was going on, but the file “Accelerometer and LCD Demo.c” is incorrect. It starts with

#pragma config(Sensor, dgtl1, xAxis, sensorAccelerometer)

which seems to indicate that the accelerometer should be plugged into a digital port, and because it is meant to be plugged into an analog port, this code doesn’t work AT ALL. Instead, you should have it configured like such:

#pragma config(Sensor, in1, xAxis, sensorAccelerometer)

  1. The numbers RobotC returns to you when you get the value of the accelerometer are completely meaningless. According to the Vex Wiki (, the output of the accelerometer, which because it is an analog sensor, is in volts. Because we know that RobotC converts voltage to an integer from 0 to 4095, corresponding linearly to 0.0V and +5.0V, using data from the Sensitivity Ranges we were able to create this chart:

Which extrapolates expected values for the accelerometer that correspond to acceleration in in/s^2. Basically, if ‘x’ is the value output from the accelerometer then y is your acceleration in in/s^2. What RobotC doesn’t tell you (including the documentation/help built in to RobotC) is that the value output from the accelerometer is encoded in some way such that the numbers RobotC returns when you use SensorValue[xAxis] are effectively meaningless.

The Solution: in your config statements, declare the sensor to be a general analog sensor instead of the Accelerometer:

#pragma config(Sensor, in1, xAxis, sensorAnalog)

By doing this, we were able to use the equation generated from the graph, which allowed us to get meaningful data from the accelerometer (of course, we still will need to account for drift, but that is a whole separate story)

I hope this post helps people who are as confused as I was when trying to use the accelerometer. If anyone who actually knows what they are doing would kindly explain exactly how RobotC is encoding the data, that would be much appreciated.