int Addr = 105; // I2C address of the L3G4200D gyro
int x, y, z,a;
int ledPinA=2;
int ledPinB=3;
void setup(){
pinMode(ledPinA,OUTPUT);
pinMode(ledPinB,OUTPUT);
Wire.begin();
Serial.begin(9600);
writeI2C(CTRL_REG1, 0x1F); // Turn on all axes, disable power down
writeI2C(CTRL_REG3, 0x08); // Enable control ready signal
writeI2C(CTRL_REG4, 0x80); // Set scale (500 deg/sec)
delay(100); // Wait to synchronize
}
void loop(){
getGyroValues(); // Get new values
Serial.print("Raw X:"); Serial.print(x /114); // Divide by 114 reduces noise
Serial.print(" Raw Y:"); Serial.print(y /114);
Serial.print(" Raw Z:"); Serial.println(z /114);
delay(300); // Short delay between reads
if(x>=20520||y>=20520||z>=20520){
//a=a+1;
digitalWrite(ledPinA,HIGH);
delay(400);
//if(a>30)
//digitalWrite(ledPinB,HIGH);
}
if(x<=-20520||y<=-20520||z<=-20520){
//a=a+1;
digitalWrite(ledPinA,HIGH);
delay(400);
//if(a>30)
//digitalWrite(ledPinB,HIGH);