Project showcase
Pushup Counter, helps with stay-at-home training!

Pushup Counter, helps with stay-at-home training! © GPL3+

This simple arduino project counts every push up you do and displays it on an LCD. It also provides visual and auditory support.

  • 1,098 views
  • 0 comments
  • 6 respects

Components and supplies

Apps and online services

About this project

With the whole corona virus thing going on, I decided to started training at home, while losing track of how many pushups I did during training, I got inspired to make this little contraption.

It counts every push up you do, (every second that you come into 10 centimeter of the ultrasonic sensor). It displays your pushup count on an LCD, makes a sound every ten pushups and shows how far you are from doing a push up with an RGB-led.

If the ultrasonic sensor detects something that is further away than 20 cm, the RGB is red, if it is between 10 - 20 cm, the RGB-led turns purple, if you are within 10 cm of the sensor, it turns blue and a point gets added to the counter. It doesn't matter how long you stay within a distance of 10 centimeters, only one point gets added per pushups, so you can take your time!

A small button can reset the counter.

Simply place the contraption on the ground, place the ultrasonic sensor under your forehead and start pushing!!

I'm very new to coding, so any feedback is appreciated!!

Code

Arduino IDE codeArduino
the code for the pushup counter
/* PUSH UP COUNTER
BY: Kyle Glerum

An ultrasonic sensor measures the distance between you and your head, if the distance is larger than 20 cm a rgb-led will shine red,
if the distance is between 10 and 20 cm, it turns magenta
and if it is less than 10 cm it turns blue, and a point appears on a lcd screen.
Every ten pushups it makes a sound.
You can reset the score with the push of a button.
 */
 
#include <LiquidCrystal.h> // include LCD library

#define BLUE 12 // define RGB-led pins
#define RED 10

const int trigPin = 8; //set pins for the ultrasonic sensor, button and buzzer
const int echoPin = 9;
const int buttonPin = A0;
const int b = 13;

long duration; // set integers
int distance;
int i;
int buttonState = 0;
int x = 1;
int y = 1;

LiquidCrystal lcd(6, 7, 2, 3, 4, 5); // set lcd pins

void setup() {
  Serial.begin(9600); // begin in 9600 baud 
  
  pinMode(trigPin, OUTPUT); //set pin modes
  pinMode(echoPin, INPUT);
  pinMode(buttonPin, INPUT);
  pinMode(b, OUTPUT);
  pinMode(RED, OUTPUT);
  pinMode(BLUE, OUTPUT);

  lcd.begin(16, 2); // begin lcd, define scale of lcd (16 places in a row, 2 rows)
  lcd.print("Push Ups:");



}

void loop() {
  digitalWrite(trigPin, HIGH); // send out an ultra sonic sound for 10 microseconds and measure the time it took for the sound to go from the trigpin to the echo pin
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration * 0.034/2; //convert the time the signal took to travel to distance in cm

  if (distance >= 20) {digitalWrite(RED, HIGH); //configure RGB-led to burn red, magenta or blue depending on distance
                       digitalWrite(BLUE, LOW);}
  if (distance <= 20) {digitalWrite(BLUE, HIGH);}
  if (distance <= 10) {digitalWrite(RED, LOW);}

  if (i == (10 * y) && x == (1 * y)) { //this if statement plays a sound every ten pushups
                 tone(b, 146.8);
                 delay(50);
                 noTone(b);
                 delay(100);
                 tone(b, 146.8);
                 delay(50);
                 noTone(b);
                 delay(50);
                 tone(b, 293.7);
                 delay(100);
                 noTone(b);
                 x ++;
                 y ++;
  }
  else if (distance <= 10) {delay(350);} //this if else statement makes sure that the time between pushup-readings always stay the same
  
  buttonState = digitalRead(buttonPin); //these lines of code resets every integer and the lcd to the original state by the press of a button
  if (buttonState == HIGH) {
    i = 0;
    x = 1;
    y = 1;
    lcd.setCursor(0,1);
    lcd.print("0      "); } 
    
  lcd.setCursor(0, 1); // set cursor on the second row
  
  if (distance <= 10 ) {i ++;} //print a point if a pushup has been done
    lcd.print(i,DEC);                 
         
  while (distance <= 10) { //if the distance stays smaller then ten for a while, this piece of code makes sure that only one point is given for one pushup
      digitalWrite(trigPin, HIGH);
      delayMicroseconds(10);
      digitalWrite(trigPin, LOW);
      duration = pulseIn(echoPin, HIGH);
      distance = duration * 0.034/2;
  delay(100);}
}

Schematics

Pushup Counter Connections
20200407 220229 hbfvhmg009
Fritzing Schematic
Untitled sketch 2 bb khua8vlkbx

Comments

Similar projects you might like

Pushup Counter

Project tutorial by Team MixPose

  • 4,109 views
  • 0 comments
  • 21 respects

Fidget Spinner RPM Counter

by Andriy Baranov

  • 59,181 views
  • 32 comments
  • 118 respects

Copy Of Fidget Spinner RPM Counter

Project in progress by CK Tan

  • 4,442 views
  • 2 comments
  • 5 respects

Interfacing Nokia 5110 LCD with Arduino

by Aqib

  • 16,103 views
  • 3 comments
  • 10 respects

Create a People Counter Controlled by an Android App

Project tutorial by Kutluhan Aktar

  • 8,138 views
  • 5 comments
  • 8 respects

Pathfinder

Project showcase by Team Maverick

  • 41,420 views
  • 22 comments
  • 171 respects
Add projectSign up / Login