初始化提交
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
// This example use I2C.
|
||||
#include "LIS3DHTR.h"
|
||||
#include <Wire.h>
|
||||
LIS3DHTR<TwoWire> LIS; //IIC
|
||||
#define WIRE Wire
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial)
|
||||
{
|
||||
};
|
||||
LIS.begin(WIRE); //IIC init dafault :0x18
|
||||
//LIS.begin(WIRE, 0x19); //IIC init
|
||||
LIS.openTemp(); //If ADC3 is used, the temperature detection needs to be turned off.
|
||||
// LIS.closeTemp();//default
|
||||
delay(100);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_2G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_4G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_8G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_16G);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_1HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_10HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_25HZ);
|
||||
LIS.setOutputDataRate(LIS3DHTR_DATARATE_50HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_100HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_200HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_1_6KHZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_5KHZ);
|
||||
LIS.setHighSolution(true); //High solution enable
|
||||
}
|
||||
void loop()
|
||||
{
|
||||
if (!LIS)
|
||||
{
|
||||
Serial.println("LIS3DHTR didn't connect.");
|
||||
while (1)
|
||||
;
|
||||
return;
|
||||
}
|
||||
//3 axis
|
||||
// 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());
|
||||
//ADC
|
||||
// Serial.print("adc1:"); Serial.println(LIS.readbitADC1());
|
||||
// Serial.print("adc2:"); Serial.println(LIS.readbitADC2());
|
||||
// Serial.print("adc3:"); Serial.println(LIS.readbitADC3());
|
||||
|
||||
//temperature
|
||||
Serial.print("temp:");
|
||||
Serial.println(LIS.getTemperature());
|
||||
delay(500);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// This example USES the ADC function.
|
||||
#include "LIS3DHTR.h"
|
||||
#include <Wire.h>
|
||||
LIS3DHTR<TwoWire> LIS; //IIC
|
||||
#define WIRE Wire
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {};
|
||||
LIS.begin(WIRE); //IIC init dafault :0x18
|
||||
//LIS.begin(WIRE, 0x19); //IIC init
|
||||
delay(100);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_2G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_4G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_8G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_16G);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_1HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_10HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_25HZ);
|
||||
LIS.setOutputDataRate(LIS3DHTR_DATARATE_50HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_100HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_200HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_1_6KHZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_5KHZ);
|
||||
LIS.setHighSolution(true); //High solution enable
|
||||
}
|
||||
void loop() {
|
||||
if (!LIS) {
|
||||
Serial.println("LIS3DHTR didn't connect.");
|
||||
while (1);
|
||||
return;
|
||||
}
|
||||
//ADC
|
||||
Serial.print("adc1:"); Serial.println(LIS.readbitADC1());
|
||||
Serial.print("adc2:"); Serial.println(LIS.readbitADC2());
|
||||
Serial.print("adc3:"); Serial.println(LIS.readbitADC3());
|
||||
delay(500);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// This example shows the 3 axis acceleration.
|
||||
#include "LIS3DHTR.h"
|
||||
#include <Wire.h>
|
||||
LIS3DHTR<TwoWire> LIS; //IIC
|
||||
#define WIRE Wire
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {};
|
||||
LIS.begin(WIRE); //IIC init dafault :0x18
|
||||
//LIS.begin(WIRE, 0x19); //IIC init
|
||||
delay(100);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_2G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_4G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_8G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_16G);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_1HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_10HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_25HZ);
|
||||
LIS.setOutputDataRate(LIS3DHTR_DATARATE_50HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_100HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_200HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_1_6KHZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_5KHZ);
|
||||
LIS.setHighSolution(true); //High solution enable
|
||||
}
|
||||
void loop() {
|
||||
if (!LIS) {
|
||||
Serial.println("LIS3DHTR didn't connect.");
|
||||
while (1);
|
||||
return;
|
||||
}
|
||||
//3 axis
|
||||
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());
|
||||
|
||||
delay(500);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
//This example show the temperature.
|
||||
// if you use the software I2C to drive the sensor, you can uncommnet the define SOFTWAREWIRE which in LIS3DHTR.h.
|
||||
|
||||
#include "LIS3DHTR.h"
|
||||
#ifdef SOFTWAREWIRE
|
||||
#include <SoftwareWire.h>
|
||||
SoftwareWire myWire(3, 2);
|
||||
LIS3DHTR<SoftwareWire> LIS;//IIC
|
||||
#define WIRE myWire
|
||||
#else
|
||||
#include <Wire.h>
|
||||
LIS3DHTR<TwoWire> LIS;//IIC
|
||||
#define WIRE Wire
|
||||
#endif
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {};
|
||||
LIS.begin(WIRE); //IIC init
|
||||
LIS.openTemp();////If ADC3 is used, the temperature detection needs to be turned off.
|
||||
// LIS.closeTemp();//default
|
||||
delay(100);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_2G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_4G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_8G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_16G);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_1HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_10HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_25HZ);
|
||||
LIS.setOutputDataRate(LIS3DHTR_DATARATE_50HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_100HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_200HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_1_6KHZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_5KHZ);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (!LIS) {
|
||||
Serial.println("LIS3DHTR didn't connect.");
|
||||
while (1);
|
||||
return;
|
||||
}
|
||||
//temperature
|
||||
Serial.print("temp:"); Serial.println(LIS.getTemperature());
|
||||
delay(500);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// This example use SPI.
|
||||
|
||||
#include "LIS3DHTR.h"
|
||||
#include "SPI.h"
|
||||
LIS3DHTR<SPIClass> LIS; //SPI
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
LIS.begin(SPI,10); //SPI SS/CS
|
||||
LIS.openTemp();//If ADC3 is used, the temperature detection needs to be turned off.
|
||||
// LIS.closeTemp();//default
|
||||
delay(100);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_2G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_4G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_8G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_16G);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_1HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_10HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_25HZ);
|
||||
LIS.setOutputDataRate(LIS3DHTR_DATARATE_50HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_100HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_200HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_1_6KHZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_5KHZ);
|
||||
}
|
||||
void loop() {
|
||||
if (!LIS) {
|
||||
Serial.println("LIS3DHTR didn't connect.");
|
||||
while (1);
|
||||
return;
|
||||
}
|
||||
//3 Axis
|
||||
// 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());
|
||||
//ADC
|
||||
// Serial.print("adc1:"); Serial.println(LIS.readbitADC1());
|
||||
// Serial.print("adc2:"); Serial.println(LIS.readbitADC2());
|
||||
// Serial.print("adc3:"); Serial.println(LIS.readbitADC3());
|
||||
//temperature
|
||||
Serial.print("temp:"); Serial.println(LIS.getTemperature());
|
||||
delay(500);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// This example USES the ADC function.
|
||||
|
||||
#include "LIS3DHTR.h"
|
||||
LIS3DHTR<TwoWire> LIS; //SPI
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
LIS.begin(SPI, 10); //SPI SS/CS
|
||||
delay(100);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_2G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_4G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_8G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_16G);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_1HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_10HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_25HZ);
|
||||
LIS.setOutputDataRate(LIS3DHTR_DATARATE_50HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_100HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_200HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_1_6KHZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_5KHZ);
|
||||
}
|
||||
void loop() {
|
||||
if (!LIS) {
|
||||
Serial.println("LIS3DHTR didn't connect.");
|
||||
while (1);
|
||||
return;
|
||||
}
|
||||
//ADC
|
||||
Serial.print("adc1:"); Serial.println(LIS.readbitADC1());
|
||||
Serial.print("adc2:"); Serial.println(LIS.readbitADC2());
|
||||
Serial.print("adc3:"); Serial.println(LIS.readbitADC3());
|
||||
delay(500);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// This example shows the 3 axis acceleration.
|
||||
|
||||
#include "LIS3DHTR.h"
|
||||
LIS3DHTR<TwoWire> LIS; //SPI
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
LIS.begin(SPI, 10); //SPI SS/CS
|
||||
delay(100);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_2G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_4G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_8G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_16G);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_1HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_10HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_25HZ);
|
||||
LIS.setOutputDataRate(LIS3DHTR_DATARATE_50HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_100HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_200HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_1_6KHZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_5KHZ);
|
||||
}
|
||||
void loop() {
|
||||
if (!LIS) {
|
||||
Serial.println("LIS3DHTR didn't connect.");
|
||||
while (1);
|
||||
return;
|
||||
}
|
||||
//3 Axis
|
||||
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());
|
||||
delay(500);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//This example show the temperature.
|
||||
|
||||
#include "LIS3DHTR.h"
|
||||
#include "SPI.h"
|
||||
LIS3DHTR<SPIClass> LIS; //SPI
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
LIS.begin(SPI, 10); //SPI SS/CS
|
||||
LIS.openTemp();////If ADC3 is used, the temperature detection needs to be turned off.
|
||||
// LIS.closeTemp();//default
|
||||
delay(100);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_2G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_4G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_8G);
|
||||
// LIS.setFullScaleRange(LIS3DHTR_RANGE_16G);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_1HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_10HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_25HZ);
|
||||
LIS.setOutputDataRate(LIS3DHTR_DATARATE_50HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_100HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_200HZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_1_6KHZ);
|
||||
// LIS.setOutputDataRate(LIS3DHTR_DATARATE_5KHZ);
|
||||
}
|
||||
void loop() {
|
||||
if (!LIS) {
|
||||
Serial.println("LIS3DHTR didn't connect.");
|
||||
while (1);
|
||||
return;
|
||||
}
|
||||
//temperature
|
||||
Serial.print("temp:"); Serial.println(LIS.getTemperature());
|
||||
delay(500);
|
||||
}
|
||||
Reference in New Issue
Block a user