The first step in accessing the compass capability from the IDE is to install a library. Finding a library that supports the module is a bit difficult, but one that works well is available at www.emartee.com/product/42254/HMC5883L%203%20Axis%20Digital%20Compass%20Module.
The following are the steps to install the library and run the example:
.rar
file that holds the library.libraries
directory of your Arduino installation.HMC5883L
library example, as shown in the following screenshot:The Raw
data is the x, y, and z data that is coming directly from the compass and is related directly to the earth's magnetic field. The Scaled
values are those that are scaled to reflect true north. The Heading
value is expressed in degrees and radians. Now, you can add direction to your project! As you move the device around, you should see the Heading
value change. These readings should give you an indication of the heading of your project. This is very useful to help you give direction to your robotic projects. However, you may want to use even more information, such as speed and tilt. Fortunately, there are sensors for this as well.
3.145.91.254