Mona Mohamed
Published

Ergonomic Chair Using Arduino

Transforming an ordinary chair to a chair that warns you when you are having unhealthy sitting.

IntermediateFull instructions provided3,649
Ergonomic Chair Using Arduino

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
1Sheeld
1Sheeld
×1
Male/Male Jumper Wires
×1
piezoelectric sensors
×2
Breadboard (generic)
Breadboard (generic)
×1
tape
×1
LED (generic)
LED (generic)
×2
Resistor 1M ohm
Resistor 1M ohm
×2
Resistor 100k ohm
Resistor 100k ohm
×2
Android device
Android device
×1

Software apps and online services

Arduino IDE
Arduino IDE
1sheeld Application

Story

Read more

Schematics

Ergonomic chair Circuit

Code

Ergonomic chair

Arduino
/* Hi, My Name is Mona, I'm going to illustrate the code 
and here is my e-mail: monamohamed816@gmail.com 
feel free to contact if you have any 
question */

#define CUSTOM_SETTINGS // to activate only the libraries that we want to use

#define INCLUDE_DATA_LOGGER_SHIELD  // includes data logger shield
#define INCLUDE_BUZZER_SHIELD // includes Buzzer shield


#include <OneSheeld.h> //includes 1sheeld library  
  
int LEDY=8; // Name of yellow LED connected to pin 8
int LEDW=9; // Name of white LED connected to pin 9
int P1=A0; // first piezoelectric sensor 
int P2=A1; // second piezoelectric sensor 
int counter =1; //Counter that counts how many unhealthy sittings you had
bool flag = false ; //when this flag is true this means that you are not leaning your back on the back of the chair (unhealthy sitting)
// when it is false then you are leaning your back ( healthy sitting) 
String keyname = "No. of Unhealthy sittings" ; //name of column in the CSV file in which the no. of unhealthy sitting is saved 
String fileName = "unHealthy sitting" ; // Name of the created file ( this file is created on your mobile in google sheets app.)

void setup() 
{ OneSheeld.begin(); // starts communication
  pinMode(LEDY , OUTPUT ) ; //set LEDY as output
  pinMode(LEDW , OUTPUT ) ; // set LEDW as output
  pinMode(P1, INPUT) ; // set first piezoelectric sensor as input
  pinMode(P2 , INPUT) ; // set second piezoelectric sensor as input
   Logger.stop(); // stops logging and saves last data logged
}


void loop() {

  digitalWrite(LEDW,LOW); //white LED is LOW at the beginning of the program
  digitalWrite(LEDY ,LOW); //yellow LED is LOW at the beginning of the program
P1= analogRead(A0) ; // saves the readings coming from pin A0 in P1 
delay(5);
P2= analogRead (A1) ; // saves the readings coming from pin A1 in P2
delay (5);


 if (P1<100 &&P2 <100) // 2 piezoelectronic sensors are not sending readings(nothing touched them)
 { digitalWrite( LEDY,LOW);
   digitalWrite(LEDW,LOW);
 Buzzer.buzzOff(); // Buzzer is off
 }

 else if ( P1 > 100 && P2 < 100 ) /* sensor on the seat detected that you sat down,while sensor on the back did't send reading ( which means 
  that you are not leaning your back) */
 
 {   Logger.stop(); 
    delay(500);
    Logger.start ("Unhealthy sitting" ); // starts logging in a new CSV file called unhealthy sitting
    digitalWrite ( LEDW ,HIGH); // when P1 is sending readings white LED is HIGH
    digitalWrite (LEDY ,LOW); // When P2 is not sending readings yellow LED is LOW
   Buzzer.buzzOn(); //Buzzer is ON
  
  flag = true ;
  }
  
  if(flag)
  {
    Logger.add ( "No. of unhealthy sittings" , counter ); // add values in the column in the CSV file
    Logger.log (); // log the row in the file 
    delay(500);
  counter++; //add 1 to the counter value
  }


 else if ( P1>100 && P2 > 100) // both piezoelectric sensors are sending readings ( which means you are sitting and leaning your back)
{ digitalWrite (LEDW ,HIGH );
  digitalWrite (LEDY ,HIGH );
  
  Buzzer.buzzOff() ;
  
  }

  else if (P1<100 && P2 > 100) // first piezoelectric is not sending readings but you are leaning your back on the chair
  //as second piezoelectric sensor is sending readings
   
  { digitalWrite (LEDY,HIGH ) ;
    digitalWrite (LEDW,LOW ) ;
    
    Buzzer.buzzOff () ;
    
    }

   else if (P1<100 && P2 <100 ) // both of them are not reading, which means you are not sitting on the chair
    {
      digitalWrite (LEDY,LOW ) ;
    digitalWrite (LEDW,LOW ) ;
    
    Buzzer.buzzOff () ;
        
      }
      
 else if (P2>100) // the sensor on the back of the chair is reading

{   digitalWrite (LEDY,HIGH ) ;
    digitalWrite (LEDW,LOW ) ;
    
    Buzzer.buzzOff () ;
  
  
}


}

Credits

Mona Mohamed

Mona Mohamed

3 projects • 5 followers
Communication and Electronics Department at Faculty of Engineering , Head of Academic staff at 3c FEHU , Social Media Manager at WIE IEEE-HSB , ROVer

Comments