Hardware Reference
In-Depth Information
Open the Arduino IDE serial monitor. You can access the serial
monitor by clicking the magnifying glass icon to the far right of
the top toolbar. Make sure the drop-down menu in the lower
right of the serial monitor is set to “9600 baud.” If you see a
constant stream of GPS data, your GPS module is correctly
installed.
The next step is to test out the compass module. With the
LSM303DLHC library installed in your Adafruit Arduino IDE,
open up the “magsensor” example, or manually enter the fol-
lowing code and upload it to your FLORA:
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_LSM303_U.h>
/* Assign a unique ID to this sensor at the same time */
Adafruit_LSM303_Mag_Unified mag =
Adafruit_LSM303_Mag_Unified ( 12345 );
void setup ( void )
{
Serial . begin ( 9600 );
Serial . println ( "Magnetometer Test" ); Serial . println ( "" );
/* Enable auto-gain */
mag . enableAutoRange ( true );
/* Initialise the sensor */
if ( ! mag . begin ())
{
/* There was a problem detecting the LSM303 ...
check your connections */
Serial . println (
"Ooops, no LSM303 detected ... Check your wiring!" );
while ( 1 );
}
}
void loop ( void )
{
/* Get a new sensor event */
sensors_event_t event ;
mag . getEvent ( & event );
/* Display the results (magnetic vector values are in
Search WWH ::




Custom Search