ADXL377 Code Help

int scale = 200;
boolean micro_is_5V = true;
int x = 90;
int y = 90;
int z = 90;
boolean led = false;
#include <SoftwareSerial.8>

void setup()
{
Serial.begin(115200);    
pinMode(LED_BUILTIN, OUTPUT);
}


void loop() 
{
int rawX = analogRead(A0);   
int rawY = analogRead(A1);
int rawZ = analogRead(A2);

float scaledX, scaledY, scaledZ; 
 if (micro_is_5V) // microcontroller runs off 5V
  {
    scaledX = mapf(rawX, 0, 675, -scaled, scaled); // 3.3/5 * 1023 =~ 675
    scaledY = mapf(rawY, 0, 675, -scaled, scaled); // 3.3/5 * 1023 =~ 675
    scaledZ = mapf(rawZ, 0, 675, -scaled, scaled); // 3.3/5 * 1023 =~ 675
  }
 else // microcontroller runs off 3.3V
  {
    scaledX = mapf(rawX, 0, 1023, -scaled, scaled);                                
    scaledY = mapf(rawY, 0, 1023, -scaled, scaled);
    scaledZ = mapf(rawZ, 0, 1023, -scaled, scaled);
  }
  
 Serial.print("X: "); Serial.print(scaledX); Serial.println(" g");
 Serial.print("Y: "); Serial.print(scaledY); Serial.println(" g");
 Serial.print("Z: "); Serial.print(scaledZ); Serial.println(" g");
 Serial.println();

 delay(20000);


if (rawX > x) || (rawY > x) || (raw Z > x)
  {
    digitalWrite(LED_BUILTIN, HIGH);
  }
}[code]

[/code]

Hey guys, I’ve been working on this code for a while and I have no idea what to do. I’m not sure what I’m doing wrong or what I should do. If anyone is feeling kind, help is much appreciated. Thanks!

-Bailey

I'm not sure what I'm doing wrong or what I should do.

You could start with telling us what the problem is.

Sorry for not explaining, i want the led to light up for 10 minutes once the accelerometer reaches 90 g's. Everytime either i get a compilation error or the accelerometer only reads at a value of 1.5 g's. I've tried calibrating the accelerometer aswell.

#include <SoftwareSerial.8>

Dot Eight?

if (rawX > x) || (rawY > x) || (raw Z > x)

Raw space Z?

What makes you think that the accelerometer can even deal with 90 Gs? What makes you think that the mapped value you get is in Gs?

Where do you turn the LED off after you have turned it on?