Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Nano-Based Posture Monitoring System with MPU6050 Sensors and Buzzer Alert

View and Edit Project In Cirkit DesignerImage of Arduino Nano-Based Posture Monitoring System with MPU6050 Sensors and Buzzer Alert

Circuit Documentation

Summary

This circuit is designed to monitor posture using a combination of a flex sensor and two MPU6050 accelerometer + gyroscope modules. The circuit includes an Arduino Nano microcontroller, LEDs to indicate good or bad posture, and a buzzer to alert the user when bad posture is detected. The system reads values from the sensors and determines if the posture is good or bad based on predefined thresholds.

Component List

  1. Resistor (220 Ohms)

    • Description: Standard resistor
    • Pins: pin1, pin2
  2. Resistor (10k Ohms)

    • Description: Standard resistor
    • Pins: pin1, pin2
  3. MPU6050 Accelerometer + Gyroscope (Wokwi Compatible)

    • Description: 6-axis motion tracking device
    • Pins: INT, AD0, XCL, XDA, SDA, SCL, GND, VCC
  4. 2.2 inch Basic Flex Resistor

    • Description: Flex sensor
    • Pins: Pin 2, pin 1
  5. Buzzer

    • Description: Piezoelectric buzzer
    • Pins: PIN, GND
  6. LED: Two Pin (red)

    • Description: Red LED
    • Pins: cathode, anode
  7. LED: Two Pin (green)

    • Description: Green LED
    • Pins: cathode, anode
  8. Arduino Nano

    • Description: Microcontroller board
    • Pins: D1/TX, D0/RX, RESET, GND, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11/MOSI, D12/MISO, VIN, 5V, A7, A6, A5, A4, A3, A2, A1, A0, AREF, 3V3, D13/SCK
  9. 9V battery

    • Description: Power source
    • Pins: +, -

Wiring Details

Resistor (220 Ohms)

Resistor (10k Ohms)

MPU6050 Accelerometer + Gyroscope (Wokwi Compatible)

2.2 inch Basic Flex Resistor

Buzzer

LED: Two Pin (red)

LED: Two Pin (green)

Arduino Nano

9V battery

Documented Code

#include <Arduino_BuiltIn.h>

const int FLEX_PIN = A0;
const int GYRO1_PIN = A1;
const int GYRO2_PIN = A2;
const int BUZZER_PIN = 9;
const int LED_GOOD_PIN = 10;
const int LED_WRONG_PIN = 11;

const int FLEX_THRESHOLD = 400;
const int GYRO_THRESHOLD = 20;

int flexValue = 0;
int gyro1Value = 0;
int gyro2Value = 0;
bool goodposture = true;

void setup() {
    Serial.begin(9600);
    pinMode(FLEX_PIN, INPUT);
    pinMode(GYRO1_PIN, INPUT);
    pinMode(GYRO2_PIN, INPUT);
    pinMode(BUZZER_PIN, OUTPUT);
    pinMode(LED_GOOD_PIN, OUTPUT);
    pinMode(LED_WRONG_PIN, OUTPUT);
}

void loop() {
    flexValue = analogRead(FLEX_PIN);
    gyro1Value = analogRead(GYRO1_PIN);
    gyro2Value = analogRead(GYRO2_PIN);

    Serial.print("Flex:");
    Serial.print(flexValue);
    Serial.print("Gyro_1:");
    Serial.print(gyro1Value);
    Serial.print("Gyro_2:");
    Serial.print(gyro2Value);

    if ((flexValue < FLEX_THRESHOLD) || (gyro1Value < GYRO_THRESHOLD) || (gyro2Value < GYRO_THRESHOLD)) {
        goodposture = false;
    } else {
        goodposture = true;
    }

    if (!goodposture) {
        digitalWrite(LED_WRONG_PIN, HIGH);
        digitalWrite(LED_GOOD_PIN, LOW);
        tone(BUZZER_PIN, 1000, 500);
    } else {
        digitalWrite(LED_GOOD_PIN, HIGH);
        digitalWrite(LED_WRONG_PIN, LOW);
    }

    delay(100);
}

This code reads the values from the flex sensor and the two MPU6050 modules. If any of the values fall below their respective thresholds, it indicates bad posture by lighting up the red LED and sounding the buzzer. If the values are above the thresholds, it indicates good posture by lighting up the green LED.