Skip to main content
improved grammar and formatting
Source Link

Accelerometre Accelerometer fix values

I use Arduino Uno with an AccelerometreAccelerometer ADXL345-gy-291 (the full name of the ship) i did hook it up like this enter image description here

note i'mNote I'm using SPI Communication, that was the right one to use in my case. when iI plug in my arduinoArduino here what does my serial monitor give me enter image description here

as you can see, it sends back fixed values no matter the movement of the ship is. the code iI use is :

#include <SparkFun_ADXL345.h>
ADXL345 adxl = ADXL345(10);

void setup(){ ` Serial.begin(9600); ` ` Serial.println("SparkFun ADXL345 Accelerometer Hook Up Guide Example");` ` Serial.println();` ` adxl.powerOn(); ` ` adxl.setRangeSetting(16); ` ` adxl.setSpiBit(0);` ` adxl.setActivityXYZ(1, 0, 0);` ` adxl.setActivityThreshold(75);` ` adxl.setInactivityXYZ(1, 0, 0);` `adxl.setInactivityThreshold(75);` ` adxl.setTimeInactivity(10);` ` adxl.setTapDetectionOnXYZ(0, 0, 1);` ` adxl.setTapThreshold(50);` ` adxl.setTapDuration(15);` ` adxl.setDoubleTapLatency(80);` ` adxl.setDoubleTapWindow(200);` ` adxl.setFreeFallThreshold(7);` ` adxl.setFreeFallDuration(30);` ` adxl.InactivityINT(1);` ` adxl.ActivityINT(1);` ` adxl.FreeFallINT(1);` ` adxl.doubleTapINT(1);` ` adxl.singleTapINT(1);` `}` `void loop(){` ` int x,y,z; ` ` adxl.readAccel(&x, &y, &z);` ` Serial.print(x);` ` Serial.print(", ");` ` Serial.print(y);` ` Serial.print(", ");` ` Serial.println(z); ` ` ADXL_ISR();` `}` `void ADXL_ISR() {` ` byte interrupts = adxl.getInterruptSource();` if(adxl.triggered(interrupts, ADXL345_FREE_FALL)){ Serial.println("*** FREE FALL ***"); }

if(adxl.triggered(interrupts, ADXL345_INACTIVITY)){ Serial.println("*** INACTIVITY ***"); }

if(adxl.triggered(interrupts, ADXL345_ACTIVITY)){ Serial.println("*** ACTIVITY ***"); }

if(adxl.triggered(interrupts, ADXL345_DOUBLE_TAP)){ Serial.println("*** DOUBLE TAP ***"); }

if(adxl.triggered(interrupts, ADXL345_SINGLE_TAP)){ Serial.println("*** TAP ***"); } }

#include <SparkFun_ADXL345.h>        
ADXL345 adxl = ADXL345(10);      
    
void setup(){
  
  Serial.begin(9600);               
  Serial.println("SparkFun ADXL345 Accelerometer Hook Up Guide Example");
  Serial.println();
  adxl.powerOn();                   
  adxl.setRangeSetting(16);         
  adxl.setSpiBit(0);
  adxl.setActivityXYZ(1, 0, 0);
  adxl.setActivityThreshold(75);
  adxl.setInactivityXYZ(1, 0, 0);
  adxl.setInactivityThreshold(75);
  adxl.setTimeInactivity(10);
  adxl.setTapDetectionOnXYZ(0, 0, 1);
  adxl.setTapThreshold(50);
  adxl.setTapDuration(15);
  adxl.setDoubleTapLatency(80);
  adxl.setDoubleTapWindow(200);
  adxl.setFreeFallThreshold(7);
  adxl.setFreeFallDuration(30);
  adxl.InactivityINT(1);
  adxl.ActivityINT(1);
  adxl.FreeFallINT(1);
  adxl.doubleTapINT(1);
  adxl.singleTapINT(1);
}
void loop(){
  int x,y,z;   
  adxl.readAccel(&x, &y, &z);
  Serial.print(x);
  Serial.print(", ");
  Serial.print(y);
  Serial.print(", ");
  Serial.println(z); 
  ADXL_ISR();
}
void ADXL_ISR() {
  byte interrupts = adxl.getInterruptSource();
  
  if(adxl.triggered(interrupts, ADXL345_FREE_FALL)){
    Serial.println("*** FREE FALL ***");
  } 
  
  if(adxl.triggered(interrupts, ADXL345_INACTIVITY)){
    Serial.println("*** INACTIVITY ***");
  }
  
  if(adxl.triggered(interrupts, ADXL345_ACTIVITY)){
    Serial.println("*** ACTIVITY ***"); 
  }
  
  if(adxl.triggered(interrupts, ADXL345_DOUBLE_TAP)){
    Serial.println("*** DOUBLE TAP ***");
  }
  

  if(adxl.triggered(interrupts, ADXL345_SINGLE_TAP)){
    Serial.println("*** TAP ***");
  } 
}

so iI wonder what was the mistake iI made there  ?

Accelerometre fix values

I use Arduino Uno with an Accelerometre ADXL345-gy-291 (the full name of the ship) i did hook it up like this enter image description here

note i'm using SPI Communication, that was the right one to use in my case. when i plug in my arduino here what does my serial monitor give me enter image description here

as you can see, it sends back fixed values no matter the movement of the ship is. the code i use is :

#include <SparkFun_ADXL345.h>
ADXL345 adxl = ADXL345(10);

void setup(){ ` Serial.begin(9600); ` ` Serial.println("SparkFun ADXL345 Accelerometer Hook Up Guide Example");` ` Serial.println();` ` adxl.powerOn(); ` ` adxl.setRangeSetting(16); ` ` adxl.setSpiBit(0);` ` adxl.setActivityXYZ(1, 0, 0);` ` adxl.setActivityThreshold(75);` ` adxl.setInactivityXYZ(1, 0, 0);` `adxl.setInactivityThreshold(75);` ` adxl.setTimeInactivity(10);` ` adxl.setTapDetectionOnXYZ(0, 0, 1);` ` adxl.setTapThreshold(50);` ` adxl.setTapDuration(15);` ` adxl.setDoubleTapLatency(80);` ` adxl.setDoubleTapWindow(200);` ` adxl.setFreeFallThreshold(7);` ` adxl.setFreeFallDuration(30);` ` adxl.InactivityINT(1);` ` adxl.ActivityINT(1);` ` adxl.FreeFallINT(1);` ` adxl.doubleTapINT(1);` ` adxl.singleTapINT(1);` `}` `void loop(){` ` int x,y,z; ` ` adxl.readAccel(&x, &y, &z);` ` Serial.print(x);` ` Serial.print(", ");` ` Serial.print(y);` ` Serial.print(", ");` ` Serial.println(z); ` ` ADXL_ISR();` `}` `void ADXL_ISR() {` ` byte interrupts = adxl.getInterruptSource();` if(adxl.triggered(interrupts, ADXL345_FREE_FALL)){ Serial.println("*** FREE FALL ***"); }

if(adxl.triggered(interrupts, ADXL345_INACTIVITY)){ Serial.println("*** INACTIVITY ***"); }

if(adxl.triggered(interrupts, ADXL345_ACTIVITY)){ Serial.println("*** ACTIVITY ***"); }

if(adxl.triggered(interrupts, ADXL345_DOUBLE_TAP)){ Serial.println("*** DOUBLE TAP ***"); }

if(adxl.triggered(interrupts, ADXL345_SINGLE_TAP)){ Serial.println("*** TAP ***"); } }

so i wonder what was the mistake i made there  ?

Accelerometer fix values

I use Arduino Uno with an Accelerometer ADXL345-gy-291 (the full name of the ship) i did hook it up like this enter image description here

Note I'm using SPI Communication, that was the right one to use in my case. when I plug in my Arduino here what does my serial monitor give me enter image description here

as you can see, it sends back fixed values no matter the movement of the ship is. the code I use is :

#include <SparkFun_ADXL345.h>        
ADXL345 adxl = ADXL345(10);      
    
void setup(){
  
  Serial.begin(9600);               
  Serial.println("SparkFun ADXL345 Accelerometer Hook Up Guide Example");
  Serial.println();
  adxl.powerOn();                   
  adxl.setRangeSetting(16);         
  adxl.setSpiBit(0);
  adxl.setActivityXYZ(1, 0, 0);
  adxl.setActivityThreshold(75);
  adxl.setInactivityXYZ(1, 0, 0);
  adxl.setInactivityThreshold(75);
  adxl.setTimeInactivity(10);
  adxl.setTapDetectionOnXYZ(0, 0, 1);
  adxl.setTapThreshold(50);
  adxl.setTapDuration(15);
  adxl.setDoubleTapLatency(80);
  adxl.setDoubleTapWindow(200);
  adxl.setFreeFallThreshold(7);
  adxl.setFreeFallDuration(30);
  adxl.InactivityINT(1);
  adxl.ActivityINT(1);
  adxl.FreeFallINT(1);
  adxl.doubleTapINT(1);
  adxl.singleTapINT(1);
}
void loop(){
  int x,y,z;   
  adxl.readAccel(&x, &y, &z);
  Serial.print(x);
  Serial.print(", ");
  Serial.print(y);
  Serial.print(", ");
  Serial.println(z); 
  ADXL_ISR();
}
void ADXL_ISR() {
  byte interrupts = adxl.getInterruptSource();
  
  if(adxl.triggered(interrupts, ADXL345_FREE_FALL)){
    Serial.println("*** FREE FALL ***");
  } 
  
  if(adxl.triggered(interrupts, ADXL345_INACTIVITY)){
    Serial.println("*** INACTIVITY ***");
  }
  
  if(adxl.triggered(interrupts, ADXL345_ACTIVITY)){
    Serial.println("*** ACTIVITY ***"); 
  }
  
  if(adxl.triggered(interrupts, ADXL345_DOUBLE_TAP)){
    Serial.println("*** DOUBLE TAP ***");
  }
  

  if(adxl.triggered(interrupts, ADXL345_SINGLE_TAP)){
    Serial.println("*** TAP ***");
  } 
}

so I wonder what was the mistake I made there?

Source Link

Accelerometre fix values

I use Arduino Uno with an Accelerometre ADXL345-gy-291 (the full name of the ship) i did hook it up like this enter image description here

note i'm using SPI Communication, that was the right one to use in my case. when i plug in my arduino here what does my serial monitor give me enter image description here

as you can see, it sends back fixed values no matter the movement of the ship is. the code i use is :

#include <SparkFun_ADXL345.h>
ADXL345 adxl = ADXL345(10);

void setup(){ ` Serial.begin(9600); ` ` Serial.println("SparkFun ADXL345 Accelerometer Hook Up Guide Example");` ` Serial.println();` ` adxl.powerOn(); ` ` adxl.setRangeSetting(16); ` ` adxl.setSpiBit(0);` ` adxl.setActivityXYZ(1, 0, 0);` ` adxl.setActivityThreshold(75);` ` adxl.setInactivityXYZ(1, 0, 0);` `adxl.setInactivityThreshold(75);` ` adxl.setTimeInactivity(10);` ` adxl.setTapDetectionOnXYZ(0, 0, 1);` ` adxl.setTapThreshold(50);` ` adxl.setTapDuration(15);` ` adxl.setDoubleTapLatency(80);` ` adxl.setDoubleTapWindow(200);` ` adxl.setFreeFallThreshold(7);` ` adxl.setFreeFallDuration(30);` ` adxl.InactivityINT(1);` ` adxl.ActivityINT(1);` ` adxl.FreeFallINT(1);` ` adxl.doubleTapINT(1);` ` adxl.singleTapINT(1);` `}` `void loop(){` ` int x,y,z; ` ` adxl.readAccel(&x, &y, &z);` ` Serial.print(x);` ` Serial.print(", ");` ` Serial.print(y);` ` Serial.print(", ");` ` Serial.println(z); ` ` ADXL_ISR();` `}` `void ADXL_ISR() {` ` byte interrupts = adxl.getInterruptSource();` if(adxl.triggered(interrupts, ADXL345_FREE_FALL)){ Serial.println("*** FREE FALL ***"); }

if(adxl.triggered(interrupts, ADXL345_INACTIVITY)){ Serial.println("*** INACTIVITY ***"); }

if(adxl.triggered(interrupts, ADXL345_ACTIVITY)){ Serial.println("*** ACTIVITY ***"); }

if(adxl.triggered(interrupts, ADXL345_DOUBLE_TAP)){ Serial.println("*** DOUBLE TAP ***"); }

if(adxl.triggered(interrupts, ADXL345_SINGLE_TAP)){ Serial.println("*** TAP ***"); } }

so i wonder what was the mistake i made there ?