Project 2 | Posture Corrector | Week 3

Setting up the Arduino with a second ultrasonic ranging module:

Now that I had the ultrasonic ranging module working, I wanted to add a second one to my Arduino in order to correct incorrect posture from multiple positions. The two main problems with posture when sitting, is people leaning forward, or people slouching. I therefore aim to use two ultrasonic ranging modules to correct the two different problems. Before setting this up I have done some further research into correcting posture in these positions.

Further research into better posture:

Slouching:

As seen in the photo below, the person is slouching, with their lower back too far from the back rest on the chair. In order to correct this, I aim to use an ultrasonic ranging module located at the rear of the chair which will indicate when your back is too far from the back rest. In order to reduce strain, the back should be placed against the back of the chair or within 2cm. I therefore plan to make the ultrasonic ranging module alarm the user if their lower back is further than 2cm from the back rest of the chair. They can then correct their posture and reduce strain.

poor-slouch

Leaning Forward:

Similarly to the image above, the image below shows a person with bad posture by leaning forwards in their chair which can also cause strain. In order to reduce this strain, the person should sit up straight in the chair and have the upper back within 5cm of the back rest on the chair. I therefore plan to have an ultrasonic ranging module to the top of the chair to alarm a user when they have leant more than 5cm forward.

See the source image

Healthy Posture:

Here is an image of someone with good posture. This is what I aim to achieve with my product.

good-posture

Link- Art of sitting | Posturite

Setting up a second ultrasonic ranging module:

Now that I had a clear idea of how to improve both posture positions, I have looked at setting up the second Ultrasonic Ranging Module with the Arduino. The video below shows a TinkerCAD setup of my code and parts. The reason the second buzzer is quiet is due to it being a passive buzzer, where as in my prototype I will use an active buzzer.

The code for the TinkerCAD:

int trigPin = 2;
int echoPin = 3;
int buzzPin = 7;
int buzzPin2 = 4;
int trigPin2 = 6;
int echoPin2 = 5;

void setup() {

  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(buzzPin, OUTPUT);
  pinMode(trigPin2, OUTPUT);
  pinMode(echoPin2, INPUT);
  pinMode(buzzPin2, OUTPUT);
}

void loop() {


  int duration, distance;
  digitalWrite (trigPin, HIGH);
  delayMicroseconds (1);
  digitalWrite (trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration / 2) / 29.1;
  Serial.print("Distance 1: ");
  Serial.print(distance);
  Serial.print("cm");
  Serial.println();

  delay (500);

  if (distance < 10) {
    digitalWrite (buzzPin, HIGH);
  }
  else {
    digitalWrite (buzzPin, LOW);
  }

  int duration2, distance2;
  digitalWrite (trigPin2, HIGH);
  delayMicroseconds (1);
  digitalWrite (trigPin2, LOW);
  duration = pulseIn(echoPin2, HIGH);
  distance2 = (duration / 2) / 29.1;
  Serial.print("Distance 2: ");
  Serial.print(distance2);
  Serial.print("cm");
  Serial.println();

  delay (500);

  if (distance2 < 10) {
    digitalWrite (buzzPin2, HIGH);
  }
  else {
    digitalWrite (buzzPin2, LOW);
  }
}

While writing this code I had a few complications, with only one ultrasonic ranging module working, even though the same code was used for them both with some slight tweaks. After working on the code for a couple hours, I realised that all I was missing was a delay between each sensor.

Once I had this working, I setup the two ultrasonic sensors to make sure my code works in real life. I didn’t have all of the parts for the setup, so I have just used the serial monitor to show the two distances being recorded correctly. In my next week I will set it up with the buzzers.