Code Analysis
#include "LIS3DHTR.h"
#ifdef SOFTWAREWIRE
#include <SoftwareWire.h>
SoftwareWire
myWire
(
3
,
2
);
LIS3DHTR<SoftwareWire> LIS(I2C_MODE);
//IIC
#define WIRE myWire
#else
#include <Wire.h>
LIS3DHTR<TwoWire> LIS(I2C_MODE);
//IIC
#define WIRE Wire
#endif
Initializing the module using software I2C or hardware I2C.
while
(!Serial) {};
Code stops here if don’t open the serial monitor, so open serial monitor.
LIS.begin(WIRE);
LIS.setOutputDataRate(LIS3DHTR_DATARATE_50HZ);
Description: Initialize the accelerator.
Syntax:
LIS.begin(Wire)
.
Description: Sets the output data rate of the accelerator.
Syntax:
LIS.setOutputDataRate(odr_type_t odr)
.
Initialize the accelerator and set the output rate to 50Hz.
Serial.print(
"x:"
); Serial.print(LIS.getAccelerationX()); Serial.print(
"
"
);
Serial.print(
"y:"
); Serial.print(LIS.getAccelerationY()); Serial.print(
"
"
);
Serial.print(
"z:"
); Serial.println(LIS.getAccelerationZ());
Description:
Functions to be used to read X-axis value from the sensor.
Syntax:
LIS.getAccelerationX(). Return type: float.
57
Grove Beginner Kit For Arduino
®
Содержание Grove Beginner Kit
Страница 1: ...Grove Beginner Kit For Arduino User Manual ...
Страница 63: ...62 Grove Beginner Kit For Arduino ...