Push-up Booster - Motivates You to Increase Pushups

by mondal3011 in Circuits > Arduino

1754 Views, 11 Favorites, 0 Comments

Push-up Booster - Motivates You to Increase Pushups

Marketing.png
FC12ENZLFTZ6NMJ.jpg

I am studying in class 12th at St. Philomena’s High School. One of my subjects is computer programming and my teacher asked us to program a simple game as a part of my assignment for the final exam. Not trying to show off my skills, but I am pretty good at programming compared to most of my classmates. I realized creating a simple scratch game would be too boring. I wanted to create a game that would have real-life benefits and something that we can physically interact with. This would not only prove my extraordinary skills to my teacher but also provide me with the best grades in the class for the subject :p

I usually exercise for an hour every morning (except on weekends of course). My workout mainly involves bodyweight exercises starting with push-ups. I have been trying hard to increase my push-up count for a long time. So I decided to kinda gamify my workout so that I can be motivated to perform more push-ups every day. Here’s the plan I came up with. 

I like to listen to music while working out. So my plan was to create a push-up counting device that will decide how long the music plays. If I want to keep the music playing, I will need to perform more push-ups. My prototype will add 30 seconds of audio playback for every rep of push-up performed. This value can of course be changed in the code. So if I'm planning to work out for one hour, I'll have to perform 120 push-ups (Each push-up adds 30 seconds of playback. So 120 push-ups will add 60 minutes). This need not be in one set. I can spread it out over multiple sets. As I get stronger and it gets easier to do the push-ups, I can edit the code to reduce the number of seconds it adds per set. This way I will have to keep increasing my push-up count to be able to listen to music throughout my workout session. 

Now with the initial idea ready, let’s start to build this workout gamification device. 

Supplies

IMG20230327103339.jpg
IMG20230327103447.jpg
IMG20230327103547.jpg

Electronics:

1x Arduino Uno

1x 5v relay module

1x IR proximity sensor

Power supply for the Arduino (5v - 12v)

Jumper wires


Tools:

Soldering iron and solder

Scissors / Wire stripper 

Pliers

Screwdriver


Miscellaneous

Adhesive / Hot glue

Insulation tape

Pencil and Eraser

Ruler

A pair of USB speakers (or whatever you use to play music during workout)


Software:

Arduino IDE

Autodesk Fusion 360 (Or fusion online)

Tinkercad (Online)

Working Principle

20230326_105955_0000.png
20230326_113919_0000.png
20230326_113919_0001.png

First, let’s plan out the working of the device. Calling it a “device” is kinda boring. Let’s call it “Push-up buddy”. So our push-up buddy needs to be able to do two main things - 

  1. Count Push-ups accurately
  2. Control music output from the speakers


To count push-ups, I have decided to use a proximity sensor. The type I am using is an infrared proximity sensor. This is a super cheap device that uses infrared light to detect if an object is close to it. Basically, it transmits infrared light from an LED and looks if the light is being bounced back from a nearby object. If it is, then it sends a signal to the microcontroller (Arduino in our case) saying, “Hey, there’s an object near me”. The Arduino can then decide what to do with that information based on what it is programmed to do. I can place this sensor on the ground right below where my head will be when I am performing the reps. Every time I go down during the push-up, the proximity sensor will detect my head and register one rep.

[Update: I came up with another perhaps more accurate way to count push-ups. Instead of a proximity sensor, we can have a reed switch. Then we can have a small magnet clipped on to our T-shirt collar. Every time the magnet gets closer to the reed switch, the switch closes and this can be registered as 1 rep. Anyways, I'm writing this after the project is done so I will still use a proximity sensor in the upcoming steps. But if you decide to use a reed switch instead, the arduino code and circuit remains the same.]


To control music playback, I couldn’t come up with a simple way to access my smartphone music app through Arduino. So I decided to control the music output from the USB speakers directly. So we will need to use speakers that are directly connected to the audio source (my phone in this case) via an aux cable. It will also work if you stream music from an FM radio channel directly from the speaker. My plan is to connect a relay between the aux cable from the speaker to the phone. If the music is to be cut off due to low reps, the relay will trigger off and the music input from the aux cable will be cut off. In case an FM radio is being used, you can simply place the relay at the power source of the speaker. When the music is to be stopped, the relay can simply cut off the power supply to the speakers. If you are using Bluetooth speakers, it's a bit tricky. You can still connect the relay at the power source to stop music playback, but every time it powers back on if you perform more push-ups, the speaker will have to connect to your phone again which will add a delay. 


[Edit: I just came up with an idea to make this work if you are using Bluetooth speakers without any pairing delay. If you have access to the inside of your speakers, you can connect the relay between the wires from the amplifier board to the speaker driver. This way you will only cut off the audio while the Bluetooth still remains connected to the phone.]

Designing the Housing on Fusion 360

IMG20230327101838.jpg
Capture.PNG
IMG20230327102016.jpg
Capture2.PNG
3Capture.PNG
4Capture.PNG
6.png
7.png
8.png
9.png

To be honest, I am an extreme beginner in CAD modeling. But thanks to my older brother who has done a lot of CAD modeling in college, I could get some good inputs about how to use the software. So these steps are going to be from the perspective of a beginner in CAD. 

One important thing to note while making any kind of housing for something, always start with a reference sketch of what will go inside the housing. It can be a simple shape like a rectangle to have a basic idea about how big the housing should be. 

We are going to place the Arduino and proximity sensor inside this housing. For this project, I am going to use a NodeMcu instead of an Arduino because it is smaller. But all the steps and codes remain the same for both. First, start with a rectangle with the dimensions of the NodeMcu (or Arduino). In my case, the nodemcu measures 25mm x 45mm. I created another rectangle for the proximity sensor which measures 20mm x 40mm. The second rectangle is inside the first one because I want to place the proximity sensor on top of the NodeMcu. This is our reference geometry and we will draw the shape of the housing around this. When taking measurements make sure to measure every bit of the component that will be inside the housing. For the proximity sensor, the two LED bulbs and the pins on the back should be considered while measuring.

Now create a new sketch and draw the housing around your reference geometry. It can be a simple rectangle, but I am making an ellipse to give it a cooler look. Now you can exit the sketch and extrude the ellipse. The height of the extruded part should be slightly greater than the combined height of the nodemcu and the proximity sensor. In my case, the total height measured 10mm. But I created a 20mm extrude because I will be creating a curve on top to further improve its design. To make the curve, you can create a sketch on the side plane with the shape you want to cut out from the top. I created an arc at a height of 15mm from either side of the extruded ellipse. Then I closed the arc and extruded it. Fusion automatically detects that you are trying to cut the ellipse and removes the material. Now it looks much cooler. Finally, I created a shell out of the body and removed the bottom surface. I have kept the wall thickness at 0.5mm. 

Some Additional Touches to the Design

Housing-v3.gif
10.png
11.png

Now that the main housing is almost done, we need to cut a slot for the proximity sensor to peek through. The two bulbs of the proximity sensor need to peek outside from the top to detect your head when you perform push-ups. For this, I used the original reference sketch to figure out where the slot should be positioned. Then I sketched a rectangle at that place. I then extrude-cut the rectangle through the housing to create a hole for the proximity sensor. Now you can say the housing is complete, but I wanted to add a few more touches. Firstly, I added filets to all sharp edges and corners of the rectangular hole. Then I created an extrude around the hole to hold the bulbs of the proximity sensor in position. This will also prevent any reflections of IR beams inside the housing. To create this extrude, I projected the hole shape to a new sketch and offset it outward by 0.5mm to create a rectangular frame. I then extruded it towards the inside. 

Downloads

Designing the Base Plate

base-plate-v2.gif
13.png
14.png

This is the part that will hold the electronics in place and the housing will come on top of this. To make the base plate, I sketched the same ellipse on the top plane. Then I extruded it by 1mm. I thought making the base thicker would be a good choice. Then I sketched another rectangle with the dimensions of the NodeMcu on top of the base plate ellipse. I then offset it outwards by 0.5mm to create a rectangular frame. Make sure to create the offset outward and not inward. Because the inner wall should be the same dimension as the NodeMcu otherwise it will not fit in! Then I extruded the rectangle frame to create a nice place for the nodemcu to slide in. This time, we should not add filets to any edges, even if they are sharp. We need to leave everything as it is so that the components can fit in smoothly. 

Downloads

Circuit Design on Tinkercad

ard2.jpg
ard4.jpg


I haven’t used Arduino a lot. I had only learned the basics of programming an Arduino. But my brother introduced me to the Tinkercad Circuit editor and that was a lifesaver for a beginner like me. Tinkercad Circuit editor is a free online tool that can simulate the working of an Arduino virtually. So we can program and test the code virtually before actually uploading it to the real board. Honestly, this has saved hours of testing and debugging. Earlier, I used to write code and upload it to the board. Then I would find there is a logical error and I have to edit the code and upload it all over again. Sometimes, this would result in multiple tests before getting the desired result from the Arduino. Now I can do all that in a few minutes on Tinkercad and once it works as intended, I can upload the final code to the real board. 


Let’s get started with the circuit design. First, we will drag and drop an Arduino UNO R3. Now we need to add the Proximity sensor. Unfortunately, I couldn’t find one on Tinkercad. So, I decided to use a push button to simulate it. It won’t make any difference to the code and working so we need not worry about it. I am going to use pin 2 to input data from the proximity sensor. So let’s add the push button between pins 2 and 3.3v. Whenever we use something like a push button or a switch as input, we will need to add a pull-down or a pull-up resistor. I am not entirely sure why this is needed, but from some tests I performed, looks like when an input pin is left open, the Arduino takes in random values as input. So to keep the value 0 when there is no input, we connect a resistor between the input pin and GND. This is called a pull-down resistor. When we will use a Proximity sensor in the real-life circuit, this pull-down resistor will not be needed. 

Wiring the Relay

ard3.jpg
ard5.jpg
ard6.jpg
ard7.jpg

Great, now let’s add the relay that will control music playback. In this case, it will be a single pole double throw (SPDT) relay. One pole and two throws make up a single-pole double-throw (SPDT) relay. One throw is regarded as normally open (NO) and the other as normally closed (NC) based on the pole's default position. You can see this from the diagram on the relay. Notice there is a coil and a switch symbol to its left. To the right of the coil is a T-shaped symbol. To understand how to make the connections, we need to understand how a relay works. Basically, a relay consists of a coil of wire and a metallic switch beside it. By default, the switch is closed to the Normally Closed (NC) contact and open to the Normally Open (NO) contact. When electricity is applied to the relay’s coil, it creates a magnetic field that pulls the switch towards it such that the switch now closes the NO contact and opens the NC contact. This way the relay operates like an electronic switch. By applying a small power to its input, it can switch a much heavier load on or off. 

So now it should be pretty easy to understand how to wire up the relay. First, we will connect the coil pins of the relay to the Arduino’s pin 5 and GND. I have chosen pin 5 as the relay pin here. Now, we will connect the music output between the Normally Open (NO) pins of the relay. Here, I am using a light bulb to represent music playback. When the bulb is on, music is playing, and when it is off, the music stops. So, one terminal of the bulb goes directly to the power supply, and the other goes to the power supply through the NO and COM (common) pins of the relay. Great! We are done designing the circuit. Before we can try it out, we need to program the Arduino. 

Programming the Arduino: Basics

4_20230327_180932_0003.png

This is where we tell the Arduino how to control our music playback based on data from the proximity sensor. If you are already familiar with programming in C (like me), it should be fairly easy to do this. The program is pretty simple in my opinion so even beginners should be able to understand it. In any case, I will upload the INO file here so that you can directly upload it to your board. 

For those who already know to program in C, here are some quick tips to get started with Arduino programming. 

  1. Every Arduino program has two functions: The setup() and the loop(). 
  2. The setup() function will run only once after the Arduino is powered ON.
  3. The loop() function will run indefinitely after the setup() function is executed. 
  4. Write your main code in the loop() function and write parts of the code that needs to run only once in the setup() function. 
  5. It is a good practice to mention which pins are for input and which are for output in the setup() function. 
  6. The syntax to output something from the Arduino is given by digitalWrite()
  7. The syntax to input something to the Arduino is given by digitalRead()
  8. The syntax to read and write in analog form instead of digital is given by analogRead() and analogWrite() respectively. 


Those basics should help you get started with this project easily. Now let’s go through the program I have written (After failing like five times).

Programming the Arduino: Detailed

cd1.jpg
cd2.jpg
cd3.jpg
cd4.jpg

First, in the setup() function, I have mentioned that pin 5 is for output and pin 2 is for input. Then I set pin 5 to LOW. LOW means OFF and HIGH means ON. The reason I set pin 5 LOW is that initially, it starts with 0 reps of push-ups so the relay needs to be OFF.  I have created a variable “musictime” that saves the amount of time music playback needs to be ON. I initially set it to 0 because of the same reason - there are no reps yet. That’s all for the setup() function!


In the loop() function, we will start with the main logic. We know that when the proximity sensor detects something (our face), the Arduino has to register a rep. So we start by saying “if pin 2 gets some input, register a rep)” For this, we use the digitalRead() function, and inside, we increment “musictime” by 15. This way, we have added 15 seconds to our music playback time. Then we enter a while loop. This is to wait until the proximity sensor is not detecting our face anymore. Or in other words, we have pushed back up. So we break the loop when the proximity sensor no longer detects our face and this completes one rep. Finally, we trigger the Relay ON if “musictime” is greater than 0. If not, we trigger the relay OFF. And finally, we decrement “musictime” by 1 and add a delay of 1000 milliseconds. This means, every iteration of the loop() function should take roughly 1 second to run and every time, we reduce the music playback time left by 1 second. Also, we only decrement “musictime” by 1 as long as it is greater than 0 because we don’t want it to go negative. 


And that’s all for the code! 


Simulating the Circuit on Tinkercad

Now if you run the simulation, you should see the bulb remain OFF by default. Once you press-hold the button and release it, the bulb will turn ON. It should remain ON for 15 seconds and turn OFF again. But if you press the button twice in a row, the bulb should remain ON for 30 seconds. In this way, the more times you push the button, the longer will the bulb remain ON. I will embed my Tinkercad circuit into this Instructable so that you can interact with my circuit and see it working too. 

Wiring Up the Proximity Sensor

Screenshot 2023-03-27 125304.jpg

Since the Tinkercad model did not include the proximity sensor, I will explain how to connect it to the Arduino in this step. Refer to the diagram I created. The proximity sensor has 3 pins - GND, D0, and VCC (Some might have an additional A0 pin that you can ignore for this project). VCC is where we need to provide it with 5v power. So we will connect this pin to the 5v pin of the Arduino. The GND pin goes to the GND of the Arduino. D0 stands for Digital Output. So this pin will go to the input pin we assigned, which is pin 2 of the Arduino. We are done connecting the proximity sensor. 

Building the Circuit in Real Life

IMG20230328124453.jpg
IMG20230328124551.jpg

Until now, all we did was virtual. Now is the time to bring it to reality. We basically need to follow the same steps as we did on Tinkercad. But there are some things we need to be careful about. Let’s begin building the circuit first. 

Before connecting the proximity sensor, we have to upload the code to Arduino. This is as simple as opening the code we wrote on Tinkercad (or you can grab it from this Instructable) on Arduino IDE, and clicking on “Upload” (Right arrow symbol). 

Now we will start by connecting the proximity sensor to the Arduino. Like the previous step, we wire it up using the corresponding pins shown in the diagram. If you refer to the picture in this step, you can see I have connected the D0 pin of the proximity sensor to pin 2 of the Arduino via the yellow wire. Next, I have GND of the proximity sensor connected to the GND of the Arduino vis the brown wire. Finally, I connected the +5v (Vcc) of the proximity sensor to the 5v pin of the Arduino via the red wire. That completes the proximity sensor part.

Testing the Circuit

ezgif.com-video-to-gif.gif
IMG20230330155143.jpg

Before connecting the relay, I decided to test if the Arduino is working as intended. To test, we can connect an LED to the Arduino pin intended for the relay. So, the LED goes to pin 5 and GND. Once that is done, we can power the Arduino either from an external power source, or the PC. When you first power it up, the LED should remain OFF. Only when you bring an object (like your hand) closer to the proximity sensor and take it away, the LED should light up. It should stay ON for 15 seconds and then turn OFF. Now if you again bring your hand close to the proximity sensor and take it away, and repeat it once more (so two times in a row), the LED should remain ON for 30 seconds. This way, every time you bring your hand close to the proximity sensor and take it away, 15 seconds should be added to the LED’s ON time. If it does exactly that, the Arduino is working perfectly as expected. If not, there is either a connection mistake (check your wiring) or a logical error in the code. 

Another reason can be the proximity sensor is not tuned to the right distance to measure. This can be easily solved by rotating the potentiometer on it (A white plastic screw-like thing) using a screwdriver until it detects your hand perfectly. 

Notice the LED only turns ON after you take your hand away from the proximity sensor. This is completely normal and is the nature of the code I have written. But something weird I noticed was the hand needs to be close to the proximity sensor for at least about half a second. If you take it off instantly, it doesn’t work. I could not figure out why this happens but this doesn’t cause any major problem with its function. 

Connecting the Relay

IMG20230328124850.jpg
IMG20230328124719.jpg

If you have a relay module board, it should be just like the connections of the proximity sensor. Vcc (or +5v) goes to 5v of the Arduino, GND goes to GND, and IN (or Signal or Input) goes to the relay pin of the Arduino, which is pin 5. But in my case, I have a bare relay so the connections are slightly different. 

The output voltage from an Arduino is usually 5v so it should be able to energize the relay coils directly. In this case, I connected the coils of the relay directly to pin 5 and the GND pin of the Arduino. These are the pins to the right and left of the centre (COM) pin of the relay. After a small test, I noticed that the Arduino could easily trigger the relay (you can hear a ‘click’ when the relay is triggered ON ).

Making Connections to the Speaker

IMG20230328143758.jpg
IMG20230328143928.jpg
IMG20230328144101.jpg
IMG20230328144317.jpg

If you are using USB speakers, it is pretty simple. All you have to do is connect the relay between one of the power supply wires or one of the wires from the AUX cable from your music source (Phone). But I have decided to use a Bluetooth speaker and there are some challenges. 

We cannot connect the relay to the power supply wires as the Bluetooth will also disconnect when the relay disconnects the power to the speaker. And there is no AUX cable to connect it to. So the only way to control the music I could find was to dismantle the speaker and connect the relay directly to the speaker driver wires. I should warn you! Do not do this if you are not confident about dismantling your speaker and putting it back together in a working condition. To be honest, I have never done this before too, but thankfully my brother helped me out with this. In fact, the speaker I am using was built by him (for which he also wrote an Instructable!) four years ago.

For this, we first unscrewed the speaker driver from the box. Then we cut one speaker wire in the middle and connected it to the relay. Now this wire is connected to the speaker driver via the NO terminal of the relay. That’s all for this part. It seems pretty easy now, but be cautious about what you are doing to your speaker if you plan on repeating this.

Putting It All Together

IMG20230330144133.jpg
Screenshot_2023-03-30-15-13-28-05_d69861e062f2821f00d6b38f4b252f2a.jpg

Ideally, we should now 3D print the housing we designed and mount all components inside. Unfortunately, I don’t have a 3D printer and neither are there any 3D printing services that will deliver my print soon. So I decided to build the housing by myself at least as of now. 

For this, I used a broken wall adapter because it had the perfect size and shape for my design. I first mounted all the components on the base with double side tape. My wire management isn’t great, but the inside will not be visible anyway. Also, I bent the proximity sensor bulbs upwards. I then made two holes for the proximity sensor bulbs on the upper housing and stuck it to the base with glue. Finally, I added a yellow cardboard bolt symbol to make it look cooler. And that’s all for the build! By the way, I made a hole on the side of the housing for the NodeMcu and speaker control wires to pass through.

Final Thoughts

IMG20230330145604.jpg
IMG20230330150137.jpg

This was definitely one of the biggest projects I have done. I am happy to see it works just as I thought it would when I started to build this. It was fun throughout the build and I am looking forward to building more such cool stuff in the future! But no matter what, there are flaws in this version of the Push-up Booster. Firstly, the speaker can now no longer be used for other purposes. Even if you want to listen to music casually when you are relaxing, it won’t play unless you get up and start doing pushups. Well on the flip side, it will give you stronger arms sooner so that's a plus XD. Another problem is the slow registering of reps. For some reason, it takes about half a second for the proximity sensor to register a rep. I don’t know why this happens but will add an update once I figure out a solution to this problem. 

Anyhow, as of now, it is a perfect workout gamification device for me and I am looking forward to improving my rep count with this!