Don't bend too much!

Made by Harshika Jain

Found in DioT 2019: Augmented Objects


Why this project

Due to sitting for long hours in campus or at home, sometimes I forget that I am slouching and end up feeling a sense of relief when I lie down in bed. Therefore I thought of building something which alerts me if I are slouching. The feedback is aimed to be delivered to a via SMS/ Whatsapp/ other popular messaging application. 

Other applications of this can be a mini sound alert system if you are flexing your finger too much after a finger injury, which is not so uncommon among people who play basketball. 


How it was built



The code did not work multiple times. The flex sensor angle kept on changing every time I deployed/ flashed code to the Argon, therefore the bending limits in the code had to be changed multiple times. Sometimes, the argon LED started working, at which point of time I unplugged it and re-ran the code on it. 


The Code

Here is a code which uses 3 components integrated together. Piezo Buzzer, Flex Sensor and LED. The flex sensor is an analogue pin and provides the input (angle of bending) while the buzzer and the LED are digital pins and provide the output, which is sound and light. The buzzer and light are meant to go off if the flex sensor is bent beyond a certain angle, therefore restricting angle limits have been set.

The code can also be viewed on Github:

// Define a pin that we'll place the FSR on
// Remember to add a 10K Ohm pull-down resistor too.
int flexPin = A0;
int flexReading = 0; // Create a variable to hold the FSR reading
int ledPin = D2; // Define a pin we'll place an LED on
int ledBrightness = 0; // Create a variable to store the LED brightness.

int piezoPin = D3;
int piezoPitch = 200; 

void setup() {
  pinMode(ledPin, OUTPUT); //set ledPin as the output pin
  pinMode(piezoPin, OUTPUT);
  Particle.variable("force", &flexReading, INT); // Create a cloud variable of type integer called 'light' mapped to photoCellReading

void loop() {
  // Use analogRead to read from the sensor
  // This gives us a value from 0 to 4095
  flexReading = analogRead(flexPin);
  //the max value is 1170 and the min is 1100

  // Map this value into the PWM range (0-255)
  // and store as the led brightness
  ledBrightness = map(flexReading, 0, 4095, 0, 255);
  piezoPitch = map(flexReading, 0, 4095, 120, 1500);
  if (flexReading > 1110 || flexReading < 1080)
      tone(piezoPin, piezoPitch, 100);
      tone(piezoPin, 0, 10);
  delay(100); // wait 1/10th of a second and then loop
    // fade the LED to the desired brightness
  analogWrite(ledPin, ledBrightness);

//I stand on the shoulders of giants
Click to Expand

Demo Video

Please watch the video in fullscreen mode as the important part is getting cut because of the automatic cropping on this webpage.

short clip depicting how it works

Next Steps

1. send a text message about straightening your back if you are slouching too much i.e. hook this with Twilio. 

2. Feed a set of strings which can be picked from when sending the message to the user to avoid irritation. 

Share this Project


49713 Designing for the Internet of Things

· 18 members

A hands-on introductory course exploring the Internet of Things and connected product experiences.

Focused on



January 30th, 2019