#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16,2); //I2C adresleme
Adafruit_MPU6050 mpu; //mpu komutlarını kullanma için tanımlama
void setup() {
Serial.begin(115200);
if (!mpu.begin()) { //mpu sensörü başlatma
while (1) {
delay(10);
}
}
lcd.init();
lcd.backlight(); //lcd ışığını yakma
lcd.setCursor(0,0);
lcd.print("MPU_6050 Sensor");
delay(1000);
}
void loop() {
sensors_event_t accel, gyro, temp; //ivme, rotasyon ve sıcaklık girdi/eventlerini tanımlama
mpu.getEvent(&accel, &gyro, &temp);
Serial.print("Acceleration on AxisX: ");
Serial.print(accel.acceleration.x);
Serial.print(", Y: ");
Serial.print(accel.acceleration.y);
Serial.print(", Z: ");
Serial.print(accel.acceleration.z);
Serial.println(" meters per second for each axis");
Serial.print("Rotation on AxisX: ");
Serial.print(gyro.gyro.x);
Serial.print(", Y: ");
Serial.print(gyro.gyro.y);
Serial.print(", Z: ");
Serial.print(gyro.gyro.z);
Serial.println(" radians per second for each axis");
Serial.print("Temperature: ");
Serial.print(temp.temperature);
Serial.println(" Celcius");
Serial.println("");
delay(1500);
lcd.clear();
lcd.print(accel.acceleration.x);
lcd.print(" ");
lcd.print(accel.acceleration.y);
lcd.setCursor(0,1);
lcd.print(accel.acceleration.z);
lcd.println(" m/s^2");
delay(1500);
lcd.clear();
lcd.print(gyro.gyro.x);
lcd.print(" ");
lcd.print(gyro.gyro.y);
lcd.setCursor(0,1);
lcd.print(gyro.gyro.z);
lcd.println(" rad/s");
delay(1500);
lcd.clear();
lcd.print("Temperature: ");
lcd.setCursor(0,1);
lcd.print(temp.temperature);
lcd.print(" ");
lcd.print("Celcius");
}