This guide has been refactored and updated for more sensors, calibration storage, and more algorithms, including quaternion output. Please visit to read the new guide!
To help you visualize the data, we've put together a basic Processing sketch that loads a 3D model (in the .obj file format) and renders it using the data generated by the AHRS sketch on the Uno. The ahsr sketch on the uno published data over UART, which the Processing sketch reads in, rotating the 3D model based on the incoming orientation data.


The OBJ library is required to load 3D models. It isn't strictly necessary and you could also render a boring cube in Processing, but why play with cubes when you have rabbits?!

Opening the Processing Sketch

The processing sketch to render the 3D model is contained in the sample folder as the ahrs sketch for the Uno.

With Processing open, navigate to you Adafruit_AHRS library folder (ex.: 'libraries/Adafruit_AHRS'), and open 'processing/bunnyrotate/bunnyrotate.pde'. You should see something like this in Processing:
Please use Processing 2.2.1 with this sketch ... newer versions have breaking changes at the API level!

Run the AHRS Sketch on the Uno

Make sure that the appropriate AHRS example sketch is running on the Uno (as described on the previous page), and that the Serial Monitor is closed.

With the sample sketch running on the Uno, click the triangular 'play' icon in Processing to start the sketch.

Rabbit Disco!

You should see a rabbit similar to the following image:
Before the rabbit will rotate you will need to click the : to the right of the serial port name. This will open a list of available serial ports, and you will need to click the appropriate serial port that your Arduino uses (check the Arduino IDE to see the port name if you're unsure). The chosen serial port should be remembered if you later run the sketch again.

As you rotate your breakout board, the rabbit should rotate to reflect the movement of the breakout in 3D-space, as seen in the video below (note that this video is using an older version of the cuberotate example and won't look exactly like what you see now):

A Note on Accuracy and Calibration

Note that the movement seen on the screen won't correlate exactly to the breakout since we are currently using uncalibrated sensor data, specifically uncalibrated magnetometer data which will throw the heading off. The magnetometer is required to generate 360° data, and if you want to improve the accuracy of your orientation data we have a tutorial on calibrating the LSM303, but this particular example starts with raw data for simplicity sake.

This guide was first published on Mar 19, 2014. It was last updated on Mar 08, 2024.

This page (Visualizing Data) was last updated on Mar 08, 2024.

Text editor powered by tinymce.