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.                       
 *		    : Michael Grant, Krazatchu Design Systems.
 * 	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()
  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(" &");
  pinMode (13,OUTPUT);

void loop()
  Serial.print(" x: ");
  Serial.print(" y: ");
  Serial.print(" z: ");

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

  digitalWrite (13,LOW);


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

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:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.