#include <Wire.h>
#include <MPU6050.h>
#include <HX711.h>
MPU6050 mpu;
HX711 scale;
const int ledPin = 13;
const int buzzerPin = 9;
const int buttonPin = 6;
bool buttonPressed = false;
void setup() {
Serial.begin(9600);
mpu.initialize();
scale.begin(A2, A3);
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
}
void loop() {
// Read accelerometer data
int16_t ax, ay, az;
mpu.getAcceleration(&ax, &ay, &az);
// Read load cell data
float weight = scale.get_units();
// Check for fall condition
if (az < -8000 && weight < 10.0) { // Replace 10.0 with your threshold weight
// Fall detected
digitalWrite(ledPin, HIGH);
tone(buzzerPin, 1000); // Activate buzzer
delay(1000); // Buzzer on for 1 second
noTone(buzzerPin); // Turn off buzzer
digitalWrite(ledPin, LOW);
// Add any other necessary actions
}
// Check if the pushbutton is pressed
if (digitalRead(buttonPin) == LOW) {
if (!buttonPressed) {
// Perform actions when the button is pressed (e.g., reset, acknowledge)
// Add your button-triggered actions here
buttonPressed = true;
}
} else {
buttonPressed = false;
}
delay(1000); // Adjust delay as needed
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
led1:A
led1:C
imu1:INT
imu1:AD0
imu1:XCL
imu1:XDA
imu1:SDA
imu1:SCL
imu1:GND
imu1:VCC
bz1:1
bz1:2
r1:1
r1:2
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r
r2:1
r2:2