Khatab Banoura
Published © CC BY-NC-SA

Arduino Smart Gym Bar

Very motivating and Interesting Gym bar

BeginnerFull instructions provided2,215
Arduino Smart Gym Bar

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
1Sheeld
1Sheeld
×1
1Sheeld
1Sheeld
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Circuit Diagram

Circuit Diagram

Code

Here's the Code

Arduino
/* This code : Counts the number of Pull ups,
Plays Music during workout,Post on facebook when U reach a milestone ,
auto Pause Music and Auto reset the counter  
Created By: Khatab Salah 
if you need help or have any notices Contact me 
at: Khatab163@gmail.com*/

#define CUSTOM_SETTINGS
#define INCLUDE_MUSIC_PLAYER_SHIELD
#define INCLUDE_TERMINAL_SHIELD
#define INCLUDE_TEXT_TO_SPEECH_SHIELD
#define INCLUDE_FACEBOOK_SHIELD
/* Include 1Sheeld library. */
#include <OneSheeld.h>
/* UltraSonic library. */ 
#include "Ultrasonic.h"

Ultrasonic ultrasonic(11, 10); //(Trig,Echo)
boolean flag, speechFlag;
int i,n;
void setup()
{
  /*Start communication*/
  OneSheeld.begin();
}

void loop() {
 /* detect motion within 70cm*/
if(ultrasonic.Ranging(CM)<70)
{
  /* check brevious State of the sensor */
   if(flag==0) 
  {
       /* Display the number on the terminal*/
       Terminal.println(n); 
       /* Set the volume. */
       MusicPlayer.setVolume(5);
       /* Turn on the music. */
       MusicPlayer.play();
       /*change the state of the sensor*/
       flag=1;
       /* reset timer*/
       i=0;  
       speechFlag = 0; 
       /* increase counter by 1 */ 
       n++;
       /*Tells the current number using text-to-speech */
       String s = "";
       s.concat(n);
       TextToSpeech.say(s);     
  }

}
else if(ultrasonic.Ranging(CM)>=70)
  {
    /* reset sensor state */
    flag=0;
    /*wait half second Every Iteration */ 
    delay(500);
    i++;
   }
   /* Facebook Post when you achieve a milestone */ 
 if (n=10)
    {
    Facebook.post(" yeaaah , a new milestone Achieved :D ");
      
    }
    /* Pause music After 20 Iteration Away from sensor (10 Seconds) */
   if(i>=20) 
   { 
     MusicPlayer.pause();
     
   }
   /* Reset Progress after 60 Iteration Away from sensor (30 Seconds*/
    if(i>=60 && speechFlag == 0)
    {
       TextToSpeech.say("You got away for too long, progress reset");  
      /* Reset Counter */    
       n=0;
       
       speechFlag = 1;
     }
}

Credits

Khatab Banoura

Khatab Banoura

1 project • 0 followers

Comments