Hello! I'm trying out your library and I'm just trying to get the simple example working. It compiles just fine but when I run it, all the Serial output doesn't get printed after the accelerometer.init(). I get the first print out but then nothing. I'm using hardware serial so I commented out the SoftwareSerial stuff, not sure why that would make a difference though.
// Basic demo for accelerometer readings from Adafruit LIS3DH
#include <Arduino.h>
#include <Wire.h>
#include <MMA8452.h>
#include <SoftwareSerial.h>
MMA8452 accelerometer;
// SoftwareSerial Serial(13, 12);
void setup()
{
Serial.begin(9600);
Serial.print(F("Initializing MMA8452Q: "));
Wire.begin();
bool initialized = accelerometer.init();
if (initialized)
{
Serial.println(F("ok"));
accelerometer.setDataRate(MMA_100hz);
accelerometer.setRange(MMA_RANGE_2G);
}
else
{
Serial.println(F("failed. Check connections."));
while (true) {};
}
}
void loop()
{
float x;
float y;
float z;
accelerometer.getAcceleration(&x, &y, &z);
Serial.print(x, 5);
Serial.print(F(" "));
Serial.print(y, 5);
Serial.print(F(" "));
Serial.print(z, 5);
Serial.println();
delay(10);
}
Serial Output:
Initializing MMA8452Q:
Hello! I'm trying out your library and I'm just trying to get the simple example working. It compiles just fine but when I run it, all the Serial output doesn't get printed after the accelerometer.init(). I get the first print out but then nothing. I'm using hardware serial so I commented out the SoftwareSerial stuff, not sure why that would make a difference though.
Serial Output:
Initializing MMA8452Q: