简体   繁体   中英

Exit status 1 Error compiling for board Arduino/Genuino Uno for Accerlerometer

So I am trying to build an accelerometer from an Arduino and this error message keeps popping up from a basic starter code I used from a library I downloaded.

Here is a link to the library:
https://github.com/adafruit/Adafruit_LIS3DH

Here is the starter code:

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_LIS3DH.h>
#include <Adafruit_Sensor.h>

// Used for software SPI
#define LIS3DH_CLK 13
#define LIS3DH_MISO 12
#define LIS3DH_MOSI 11
// Used for hardware & software SPI
#define LIS3DH_CS 10

//software SPI
Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS, LIS3DH_MOSI,
LIS3DH_MISO,LIS3DH_CLK);
//hardware SPI
Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS);
//I2C
Adafruit_LIS3DH lis = Adafruit_LIS3DH();

#if defined(ARDUINO_ARCH_SAMD)
// for Zero, output on USB Serial console, remove line below if using 
programming port to program the Zero!
#define Serial SerialUSB
#endif
void setup(void) {
#ifndef ESP8266
  while (!Serial);     // will pause Zero, Leonardo, etc until serial 
console opens
#endif

Serial.begin(9600);
Serial.println("LIS3DH test!");

if (! lis.begin(0x18)) {   // change this to 0x19 for alternative i2c 
address
Serial.println("Couldnt start");
while (1);
  }
Serial.println("LIS3DH found!");

lis.setRange(LIS3DH_RANGE_4_G);   // 2, 4, 8 or 16 G!

Serial.print("Range = "); Serial.print(2 << lis.getRange());  
Serial.println("G");
}

void loop() {
lis.read();      // get X Y and Z data at once
// Then print out the raw data
Serial.print("X:  "); Serial.print(lis.x); 
Serial.print("  \tY:  "); Serial.print(lis.y); 
Serial.print("  \tZ:  "); Serial.print(lis.z); 

/* Or....get a new sensor event, normalized */ 
sensors_event_t event; 
lis.getEvent(&event);

/* Display the results (acceleration is measured in m/s^2) */
Serial.print("\t\tX: "); Serial.print(event.acceleration.x);
Serial.print(" \tY: "); Serial.print(event.acceleration.y); 
Serial.print(" \tZ: "); Serial.print(event.acceleration.z); 
Serial.println(" m/s^2 ");

Serial.println();

delay(200); 
}

And here is the error message:

Arduino: 1.8.5 (Mac OS X), Board: "Arduino/Genuino Uno"

Build options changed, rebuilding all
In file included from /Users/smcmahon/Documents/Arduino/libraries/Adafruit_LIS3DH-master/examples/acceldemo/acceldemo.ino:5:0:
/Users/smcmahon/Documents/Arduino/libraries/Adafruit_LIS3DH-master/Adafruit_LIS3DH.h:34:29: fatal error: Adafruit_Sensor.h: No such file or directory
 #include <Adafruit_Sensor.h>
                             ^
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

You are obviously missing the Adafruit_Sensor library.

Install it from:
https://github.com/adafruit/Adafruit_Sensor

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM