HiTechnic NXT Acceleration Sensor for LEGO Mindstorms NXT
Introduction
The NXT Acceleration Sensor contains a three axis accelerometer that measures acceleration in three axes, x, y and z. Acceleration is measured in the range of –2g to +2g with scaling of approximately 200 counts per g.
The Acceleration Sensor connects to an NXT sensor port using a standard NXT wire and uses the digital I2C communications protocol. The acceleration measurement for each axis is refreshed approximately 100 times per second.
The three axes of measurement are labeled x, y, and z as shown.

The Acceleration Sensor can also be used to measure tilt in three axes. This is possible because gravity is perceived as acceleration. When the sensor is stationary and in the normal horizontal position, the x and y axis will be near zero, because they are horizontal, while the z axis will be near 200, which represents one g. If you tilt the sensor then gravity will also be detected on the other axis and the value for the z axis will go down. Since gravity is distributed among the three component vectors, the tilt of the sensor can be determined.
To test your new sensor, plug it into port 2 of your NXT and select View > Ultrasonic cm > Port 2. Hold the sensor level in your hand and slowly tilt it forward and back. The value displayed on the NXT will represent the acceleration or tilt value for the x axis and will be in the range of 0 - 254. (0 will display as ?????? while in View mode.) Note that only the x axis can be displayed using the view function.
Programming
Mindstorms NXT-G
The Acceleration Sensor can be programmed using LEGO Mindstorms NXT Software using the Acceleration Sensor Block available as a download.
Acceleration Sensor Block
The Acceleration Block will return the value for the positive or negative acceleration for each axis, x, y and z as shown.
In additon, a trigger point may be set for the x axis. The conditions for the trigger will be met whenever the x axis value exceeds the trigger.
Configuring the Acceleration Sensor Block
- Choose the port where your Acceleration sensor is plugged in. By default, the block will be set to port 3 for an acceleration sensor. You can change this selection if you need to.
- If you choose the Compare function, the block will be triggered when the x axis reading is above or below the selected value; select < "less than" to trigger the block when the reading is below the trigger value or > "greater than" to trigger the block when the reading is above the trigger value. Use the slider to set the trigger value or type it directly into the input box.
Sensor Register Layout
Address |
Type |
Contents |
42H |
byte |
X axis upper 8 bits |
43H |
byte |
Y axis upper 8 bits |
44H |
byte |
Z axis upper 8 bits |
45H |
byte |
X axis lower 2 bits |
46H |
byte |
Y axis lower 2 bits |
47H |
byte |
Z axis lower 2 bits |
Notes:
-
NXT Firmware version 1.05 or later must be loaded in the NXT for the Acceleration Sensor and other digital I2C sensors to operate correctly. You can check the firmware version by displaying the NXT Window in the Mindstorms software.
Other Programming Environments
NXC Programming
Current version of NXC includes an api function for reading the HiTechnic Acceleration Sensor.
bool ReadSensorHTAccel (const byte port, int &x, int &y, int &z)
For a complete list of HiTechnic API supported by NXC, please refer to the HiTechnic API page of the online NXC Programmer's Guide.
//====================================================================
// Sample Program to display the values from the
// HiTechnic Acceleration Sensor attached to Port 1
//
task main()
{
int x,y,z;
SetSensorLowspeed(S1);
Wait(50);
while(true) {
ReadSensorHTAccel(S1, x, y, z);
TextOut(0, LCD_LINE1, "x: ");
NumOut(6*2, LCD_LINE1, x);
TextOut(0, LCD_LINE2, "y: ");
NumOut(6*2, LCD_LINE2, y);
TextOut(0, LCD_LINE3, "z: ");
NumOut(6*2, LCD_LINE3, z);
Wait(100);
}
}
RobotC
The Acceleration Sensor can also be used with RobotC using the functions provided by the drivers pack available under RobotC below.
Downloads
New with version 2.0: This block adds support for the HiTechnic Sensor Multiplexer as well as data logging with the LEGO Mindstorms 2.0 Education software.
| Description | Version | Release Date | Size | ||
| HiTechnic Acceleration Sensor Block for Mindstorms NXT Software | 2.0 | July 29th, 2010 | 420.43 KB | Download Now |
Note:This version uses the 2.0 Acceleration Sensor block as well as the new HiTechnic Motor PID block.
Tip: The easiest way to install is to copy the .rbtx file from this zip file into a new Profile folder in your LEGO Mindstorms document file tree. Please see the readme.txt file for more information.
| Description | Version | Release Date | Size | ||
| HiTechnic BallShooter V2 for LMS 2.0 | 2.0 | May 4th, 2011 | 993.72 KB | Download Now |
Note:This version uses the 2.0 Acceleration Sensor block as well as the new HiTechnic Motor PID block.
Tip: The easiest way to install is to copy the files from this zip file into a new Profile folder in your LEGO Mindstorms document file tree. Please see the readme.txt file for more information.
| Description | Version | Release Date | Size | ||
| HiTechnic BallShooter V2 for LMS 1.0 | 2.0 | May 4th, 2011 | 804.73 KB | Download Now |
New with version 1.1: This version uses the new 2.0 Acceleration Sensor block.
| Description | Version | Release Date | Size | ||
| HiTechnic Remote Control programs for Mindstorms NXT-G | 1.1 | October 27th, 2010 | 464.39 KB | Download Now |
| Description | Version | Release Date | Size | ||
| FTC Update For LabVIEW 2009 | 1.0 | October 6th, 2010 | 261.37 KB | Download Now |
| Description | Version | Release Date | Size | ||
| Acceleration Sensor VI For LabVIEW2009 | 1.0 | October 6th, 2010 | 61.30 KB | Download Now |
| Description | Version | Release Date | Size | ||
| Acceleration Sensor VI | 1.0 | April 2nd, 2009 | 45.89 KB | Download Now |
| Description | Version | Release Date | Size | ||
| HiTechnic Ball Shooter Building Instructions | 1.0 | September 1st, 2010 | 9.73 MB | Download Now |
New with v. 0.21: Gyro Sensor block now available with the other analog sensor blocks.
New with v. 0.20: Added support for the RPM value for Angle sensor. Split blocks into individual .ev3b files so you only need to import what you need. Worked around EV3 IIC U8 as I8 bug.
| Description | Version | Release Date | Size | ||
| HiTechnic EV3 I2C Blocks | 0.21 | February 7th, 2014 | 103.77 KB | Download Now |






