Project tutorial
Push-up Counter using Arduino and Ultrasonic Sensor

Push-up Counter using Arduino and Ultrasonic Sensor © GPL3+

How to make a Push-up Counter using Arduino and Ultrasonic Sensor HC SR04, 4 digital 7 segment display

  • 420 views
  • 1 comment
  • 2 respects

Components and supplies

Apps and online services

About this project

I like to push-up the exercise. I do it about 10 times at a time, but sometimes I get tired and don't make the right move down and up high enough, and I don't remember the number of times. So I made a counter to follow the rules. I choose arduino to be the control circuit, an ultrasonic sensor to determine the number of times the body goes up and down an 7 segment display to show the result. The counter can be reset for next time.

I hope that you like this project. And subscribe my youtube channel.

Thanks for your watching!!!

Code

Push up counter codeC/C++
#include <TM1637Display.h>
//HC-SR04
#define echoPin  2
#define trigPin  3
#define resetPin 4

// 4-digital display pins (Digital Pins)
#define CLK 8
#define DIO 9
TM1637Display display(CLK, DIO);

float duration; //micro second
float d_cm;
long numDisplay=100;
boolean trigUp = false;
boolean trigDown = false;
float counterPushUp=0;

void setup() {

// initialize serial communication:
  Serial.begin(9600);
  pinMode(trigPin,OUTPUT);
  pinMode(echoPin,INPUT);
  //
  pinMode(resetPin,INPUT_PULLUP);
  //
  display.setBrightness(4);
  display.clear();
  delay(500);
  display.showNumberDecEx(numDisplay, false, true, 4, 0);
}

void loop() {
  
  //reset by switch
  if(digitalRead(resetPin)==0){
    trigUp=false;
    trigDown=false;
    counterPushUp=0;
  }
  
  // generate pusle trigger
  digitalWrite(trigPin,LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin,HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin,LOW);
  // receive, convert time (us) to cm
  duration = pulseIn(echoPin,HIGH);
  d_cm = duration * 0.034/2.;
  
  //trigger body 
  if (d_cm>15 && d_cm<=30){
    trigUp = true;
  } else if (d_cm < 10){
    trigDown = true;
  } else if(d_cm >30) {
  }
  //counter
  if (trigUp==true && trigDown==true){
    counterPushUp=counterPushUp+0.5;
    trigUp=false;
    trigDown=false;
  }
  //print
//  Serial.print(d_cm);
//  Serial.print(" --- ");
//  Serial.println(counterPushUp);
  display.showNumberDecEx(counterPushUp, false, true, 4, 0);
}

Custom parts and enclosures

Push up counter schematic fritzing
pushupdiagram_vLv2dE3D5c.fzz

Schematics

Push up counter schematic
Pushupdiagram bb ri7c8dkvfi

Comments

Similar projects you might like

Ultrasonic Sensor with Alarm, LCD and Temperature

Project tutorial by MichDragstar

  • 15,064 views
  • 10 comments
  • 31 respects

IOT - Smart Jar Using ESP8266, Arduino and Ultrasonic Sensor

Project tutorial by Team Smazee

  • 12,614 views
  • 5 comments
  • 16 respects

Pushup Counter

Project tutorial by Team MixPose

  • 4,853 views
  • 0 comments
  • 24 respects

Ultrasonic Security System

Project tutorial by Ivan

  • 51,667 views
  • 40 comments
  • 126 respects
Add projectSign up / Login