I have a trouble with following, few lines code. For some reason after few seconds Arduino uno stops responding into void loop section of code. I tried to remove serial communication, all print and println without any success. Is the problem comming from MMA_7455.h?
#include <MMA_7455.h>
#include <Servo.h>
int servoPin = 9;
int servoAngle = 0;
Servo servo;
MMA_7455 accel = MMA_7455();
char yVal;
char yVal_bkp;
void setup() {
servo.attach(servoPin);
accel.initSensitivity(2);
accel.calibrateOffset(1.0, 26.0, -69.0);
}
void loop() {
yVal = accel.readAxis('y'); //Read out the 'y' Axis
if(yVal_bkp != yVal + 2 || yVal_bkp != yVal -2)
{
servo.write(90 + yVal);
yVal_bkp = yVal;
}
}
P.S. Servo is normal G90