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

Arduino Nano-Based Posture Detector with MPU6050 Gyroscopes and Flex Sensor

View and Edit Project In Cirkit DesignerImage of Arduino Nano-Based Posture Detector with MPU6050 Gyroscopes and Flex Sensor

Circuit Documentation

Summary

The circuit in question appears to be designed for posture monitoring, utilizing a combination of flex sensors and gyroscopes to detect the user's posture. It includes an Arduino Nano as the central microcontroller, which processes the sensor data and provides feedback through LEDs and a buzzer. The circuit is powered by a 9V battery and includes resistors for current limiting and pull-down configurations.

Component List

Resistors

Sensors

Actuators

Power Supply

Microcontroller

Wiring Details

Buzzer

LEDs

Flex Sensor

MPU6050 Accelerometer + Gyroscope

Resistors

Power Supply

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.println(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); // Sound the buzzer at 1kHz for 500ms
  } else {
    digitalWrite(LED_GOOD_PIN, HIGH);
    digitalWrite(LED_WRONG_PIN, LOW);
  }

  delay(100);
}

The code is designed to read values from the flex sensor and two gyroscopes. If any of the readings fall below predefined thresholds, it is assumed that the posture is incorrect. In such a case, the red LED is turned on, the green LED is turned off, and the buzzer is activated. If the posture is correct, the green LED is turned on, and the red LED is turned off. The sensor values and posture status are printed to the serial monitor for debugging purposes.