sparkfun H3LIS331DL Breakout Hookup Manual page 9

Accelerometer
Table of Contents

Advertisement

S PA R K F U N L I S 3 3 1 A R D U I N O
For the most part, the example code for SPI mode and I C mode is
identical. The only part that differs is the intial setup where you configure
the pins to be used and the library's settings.
I C Mode Setup
2
Here's an example of the same section of code from an I C configured
system. It's important to note that order matters here:
must be called before
xl.setI2CAddr()
#include "SparkFun_LIS331.h"
#include <Wire.h>
LIS331 xl;
void setup()
{
// put your setup code here, to run once:
pinMode(9,INPUT);
// Interrupt pin input
Wire.begin();
xl.setI2CAddr(0x19);
// This MUST be called BEFORE .begin
() so
//
e chip
xl.begin(LIS331::USE_I2C); // Selects the bus to be used an
d sets
//
meter.
//
r
//
e.
SPI Mode Setup
Here we have the first few lines of an SPI mode sketch. Again, order is
important:
,
pinMode()
SPI.begin()
must all be called before the
xl.begin()
L I B RA RY
2
2
Wire.begin()
.
xl.begin()
.begin() can communicate with th
the power up bit on the accelero
Also zeroes out all acceleromete
registers that are user writabl
, and
functions
xl.setSPICSPin()
function is called.
and
Page 9 of 12

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the H3LIS331DL and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Table of Contents