MMA8452Q tilt sensor

Hi, I'm new to programming Arduino so if someone could help that would be great . I'm looking at switching output (13) HIGH when tilt sensor reading is 200 or higher. When i monitor the x axes
i get reading from 250 / -250 when rotating 180 degrees . Thanks

/************************************************************************************
 * 	
 * 	Name    : MMA8453_n0m1 Library Example: DataMode                       
 * 	Author  : Noah Shibley, NoMi Design Ltd. http://n0m1.com                       
 *		    : Michael Grant, Krazatchu Design Systems. http://krazatchu.ca/
 * 	Date    : May 5th 2013                                    
 * 	Version : 0.2                                              
 * 	Notes   : Arduino Library for use with the Freescale MMA8453Q via Arduino native WIRE with repeated start (was i2c of DSS circuits). 
 *
 ***********************************************************************************/

#include <Wire.h>
#include <MMA8453_n0m1.h>

MMA8453_n0m1 accel;

void setup()
{
  Serial.begin(9600);
  accel.setI2CAddr(0x1D); //change your device address if necessary, default is 0x1C
  accel.dataMode(true, 2); //enable highRes 10bit, 2g range [2g,4g,8g]
  Serial.println("MMA8453_n0m1 library");
  Serial.println("XYZ Data Example");
  Serial.println("n0m1.com & krazatchu.ca");
  pinMode (13,OUTPUT);
}

void loop()
{
  accel.update();
  
  Serial.print(" x: ");
  Serial.print(accel.x());
  Serial.print(" y: ");
  Serial.print(accel.y());
  Serial.print(" z: ");
  Serial.println(accel.z());

  if (Serial.print(accel.x) <=200)
   digitalWrite (13,HIGH);

  else
  digitalWrite (13,LOW);

}

Serial.print returns the number of characters output.
In your case, I imagine this will always be less than 200
HTH

Please remember to use code tags when posting code

Hi, @zoofly
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

Tom... :grinning: :+1: :coffee: :australia: