#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <LiquidCrystal.h>
Adafruit_MPU6050 mpu;
float fall_vel;
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
lcd.begin(16,2);
if(!mpu.begin()){
Serial.println("failed to initialize mpu");
while(1){
delay(10);
}
}
Serial.println("MPU found");
mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
mpu.setGyroRange(MPU6050_RANGE_500_DEG);
mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
delay(100);
}
int t=0;
void loop() {
// put your main code here, to run repeatedly:
sensors_event_t a,g,temp;
mpu.getEvent(&a,&g,&temp);
Serial.println(a.acceleration.y);
float acc=a.acceleration.y;
fall_vel=acc*t;
lcd.setCursor(0,1);
lcd.print(fall_vel);
delay(1000);
t++;
}