|
|
|
|
@ -14,6 +14,8 @@ MPU6050 mpu6050(Wire);
|
|
|
|
|
int counter = 0;
|
|
|
|
|
long timer = 0;
|
|
|
|
|
int bmePresent;
|
|
|
|
|
int greenLED = 9;
|
|
|
|
|
int blueLED = 8;
|
|
|
|
|
int Sensor1 = 0;
|
|
|
|
|
int Sensor2 = 0;
|
|
|
|
|
float Sensor3 = 0;
|
|
|
|
|
@ -119,12 +121,35 @@ void loop() {
|
|
|
|
|
Serial.print(" ");
|
|
|
|
|
Serial.print(mpu6050.getGyroZ());
|
|
|
|
|
|
|
|
|
|
Serial.print(" XS ");
|
|
|
|
|
Serial.print(Sensor1);
|
|
|
|
|
Serial.print(" ");
|
|
|
|
|
Serial.print(Sensor2);
|
|
|
|
|
Serial.print(" ");
|
|
|
|
|
Serial.println(Sensor3);
|
|
|
|
|
Serial.print(" ");
|
|
|
|
|
Serial.print(mpu6050.getAccX());
|
|
|
|
|
Serial.print(" ");
|
|
|
|
|
Serial.print(mpu6050.getAccY());
|
|
|
|
|
Serial.print(" ");
|
|
|
|
|
Serial.print(mpu6050.getAccZ());
|
|
|
|
|
|
|
|
|
|
Serial.print(" XS ");
|
|
|
|
|
Serial.print(Sensor1);
|
|
|
|
|
Serial.print(" ");
|
|
|
|
|
Serial.print(Sensor2);
|
|
|
|
|
Serial.print(" ");
|
|
|
|
|
Serial.println(Sensor3);
|
|
|
|
|
|
|
|
|
|
float rotation = sqrt(mpu6050.getGyroX()*mpu6050.getGyroX() + mpu6050.getGyroY()*mpu6050.getGyroY() + mpu6050.getGyroZ()* mpu6050.getGyroZ());
|
|
|
|
|
float acceleration = sqrt(mpu6050.getAccX()*mpu6050.getAccX() + mpu6050.getAccY()*mpu6050.getAccY() + mpu6050.getAccZ()*mpu6050.getAccZ());
|
|
|
|
|
// Serial.print(rotation);
|
|
|
|
|
// Serial.print(" ");
|
|
|
|
|
// Serial.println(acceleration);
|
|
|
|
|
|
|
|
|
|
if (acceleration > 1.2)
|
|
|
|
|
digitalWrite(greenLED, HIGH);
|
|
|
|
|
else
|
|
|
|
|
digitalWrite(greenLED, LOW);
|
|
|
|
|
|
|
|
|
|
if (rotation > 5)
|
|
|
|
|
digitalWrite(blueLED, HIGH);
|
|
|
|
|
else
|
|
|
|
|
digitalWrite(blueLED, LOW);
|
|
|
|
|
|
|
|
|
|
// Serial1.println(counter++);
|
|
|
|
|
}
|
|
|
|
|
@ -168,12 +193,35 @@ void loop() {
|
|
|
|
|
Serial1.print(" ");
|
|
|
|
|
Serial1.print(mpu6050.getGyroZ());
|
|
|
|
|
|
|
|
|
|
Serial1.print(" XS ");
|
|
|
|
|
Serial1.print(Sensor1);
|
|
|
|
|
Serial1.print(" ");
|
|
|
|
|
Serial1.print(Sensor2);
|
|
|
|
|
Serial1.print(" ");
|
|
|
|
|
Serial1.println(Sensor3);
|
|
|
|
|
Serial1.print(" ");
|
|
|
|
|
Serial1.print(mpu6050.getAccX());
|
|
|
|
|
Serial1.print(" ");
|
|
|
|
|
Serial1.print(mpu6050.getAccY());
|
|
|
|
|
Serial1.print(" ");
|
|
|
|
|
Serial1.print(mpu6050.getAccZ());
|
|
|
|
|
|
|
|
|
|
Serial1.print(" XS ");
|
|
|
|
|
Serial1.print(Sensor1);
|
|
|
|
|
Serial1.print(" ");
|
|
|
|
|
Serial1.print(Sensor2);
|
|
|
|
|
Serial1.print(" ");
|
|
|
|
|
Serial1.println(Sensor3);
|
|
|
|
|
|
|
|
|
|
float rotation = sqrt(mpu6050.getGyroX()*mpu6050.getGyroX() + mpu6050.getGyroY()*mpu6050.getGyroY() + mpu6050.getGyroZ()* mpu6050.getGyroZ());
|
|
|
|
|
float acceleration = sqrt(mpu6050.getAccX()*mpu6050.getAccX() + mpu6050.getAccY()*mpu6050.getAccY() + mpu6050.getAccZ()*mpu6050.getAccZ());
|
|
|
|
|
// Serial.print(rotation);
|
|
|
|
|
// Serial.print(" ");
|
|
|
|
|
// Serial.println(acceleration);
|
|
|
|
|
|
|
|
|
|
if (acceleration > 1.2)
|
|
|
|
|
digitalWrite(greenLED, HIGH);
|
|
|
|
|
else
|
|
|
|
|
digitalWrite(greenLED, LOW);
|
|
|
|
|
|
|
|
|
|
if (rotation > 5)
|
|
|
|
|
digitalWrite(blueLED, HIGH);
|
|
|
|
|
else
|
|
|
|
|
digitalWrite(blueLED, LOW);
|
|
|
|
|
|
|
|
|
|
// Serial1.println(counter++);
|
|
|
|
|
}
|
|
|
|
|
|