I recently finished a DIY garage gym clock powered by an
Arduino micro controller and accessorized with a fire alarm bell for start and stop cueing. So far it’s been working great!
Why? I wanted to build a timer/stopwatch rather than use a smart phone app. #1 for the challenge, and #2 to have a dedicated portable, or, semi-permanent clock.
When I searched online for similar Arduino-based projects, the closest I could find was a project called the “Griz 9000” which looked exactly like what I was looking for, except the display was a little larger than I desired and looked like it required a bit more programming work.
Step 1: Building Steps and Design Goals
These are the high level steps you will generally follow to complete this project. This may vary depending on your experience, parts you have on hand, etc.
- Read and understand all the steps.
- Acquire the parts and tools.
- Build the test circuit. This includes some minor soldering required to assemble the display.
- Upload Arduino code to the test circuit.
- Test functionality.
- Final assembly. Fitting the Arduino, display and everything else into your chosen container.
- Stopwatch Function
- Countdown Timer Function
- Tabata Program Function
- Buzzer or Bell
- IR Remote Control
Step 2: Gather Parts
- ArduinoPro. I had one I previously purchased during a sale from www.sparkfun.com, so it was slightly cheaper for me. Any Arduino Uno compatible 5 volt board should work though from www.sparkfun.com, www.amazon.com, etc.
- Adafruit 1.2″ 4-Digit 7-Segment Display w/I2C Backpack. This is the display. It has adjustable brightness and as the name suggests, has 1.2” high digits.
- IR (Infrared) Receiver Sensor – TSOP38238. This is the small black bubble-looking thing that receives input when you push buttons on your remote control.
- Mini Remote Control. I used this one from www.adafruit.com. Any IR remote could potentially work though.
- Breadboard-friendly 2.1mm DC barrel jack for power from either a battery or 12v transformer.
- TIP120 Power Darlington Transistors ($2.50 for 3). This transistor triggers the solenoid to ring the bell when signaled by the Arduino.
- 12V 5A switching power supply ($24.95) I happened to have an extra one of these laying around so this part was free.
- (Optional) 7Ah battery. This can be used to power the clock when you’re training in a parking lot or other outside location without AC power.
- (Optional) Male DC Power adapter – 2.1mm plug to screw terminal block ($2.00) This is for rigging up a connector to the 7 Ah battery.
- 1N4001 Diode. This is part of the solenoid piece of the circuit to prevent a voltage spike from harming the Arduino.
- Ammo Can. Or lunchbox, etc. Get creative.
- Push-Pull solenoid. This rings the bell. I tried this small one from Adafruit but it didn’t quite have enough oomph, so I ended up using this larger one from Amazon.com.
- 6” fire alarm bell from www.ebay.com I took out the guts of the ringer system and screwed the solenoid in place to ring the bell.
- Toggle switch. Every project needs a big toggle switch.
- Tubing to use as a border around the display and help prevent sheet metal injuries. I used green plastic sprinkler tubing which I slit lengthwise to form around the rectangular opening.
Step 3: Gather Tools
- Soldering Iron
- Wire cutters
- Wire strippers
- Drill and bits
- Jigsaw and metal cutting blade
- Hot glue gun and glue sticks
- Electrical tape
Step 4: Build the Circuit (Breadboard)
Attached is a picture of the circuit diagram. You can see the digital and analog pins I used on the Arduino for each component (really tiny lettering in white). You don’t have to use the exact pins, but if you change them, they must be changed in the Arduino program as well.
I highly recommend first building this using a breadboard and temporary wiring to see if it actually works before committing to final soldering and assembly. If this is your first adventure with Arduino, I recommend starting with something like this Starter Pack from www.adafruit.com to get your hands dirty and get your computer set up to be able to successfully program the Arduino, meaning being able to get code from your computer to the Arduino via a USB cable.
Step 5: Program the Arduino
Just gimme the code and let me try it out: OK, here it is on GitHub (make sure you have dependent libraries installed – see #1 below): https://github.com/wagraeme/garage-gym-timer
For a little more detail, but not too much in the weeds:
I won’t go into too much detail about the code, just try to highlight my thought process, functions used, and things to watch out for. The code is a conglomeration of snippets and pieces built from trial and error, various tutorials, and lots of Googling. I wanted to keep it as simple as possible, extensible in the future, and based on a Finite State Machine (FSM), menu-driven model.
Starting at the top:
- There are 4 include statements at the top of the sketch (aka program – “sketch” in the Arduino world). You will need to ensure you have the correct libraries installed referenced by these include statements. Work through the Adafruit tutorial on installing libraries – very helpful!
- I defined various ‘states’, ‘actions’, and ‘events’ for my rudimentary ‘menu/settings’ system for the IR remote. By the way, you can use any remote you want, you just need to discover the specific IR codes when buttons are pressed. Start with this guide if you’re curious about this: Using an Infrared Library on Arduino
- Define pins used on the Arduino for the IR receiver and solenoid.
- Define other global variables like start/stop flags, duration between bell dings, display brightness, etc.
- Setup loop. This is a loop run just once when the Arduino first boots up.
- Main loop. The main loop runs continuously while the Arduino is powered on. The main loop for this project is a switch statement with about 10 or so case statements mapping to the ‘menu’ system.
- Define all the functions used in the case statements in #6 above. For example, the start stopwatch function, stop stopwatch function, start timer, stop timer, etc.
That’s pretty much it for a high-level description. There are some comments in the code where I try to explain the major pieces as well.
Step 6: Testing and Final Assembly
After your circuit works on a breadboard with the code uploaded into the Arduino, it’s time for final soldering, testing, and assembly.
There was a lot of sketching with a pencil and trial and error on the ammo can to see where the final parts would fit, namely the display and the bell. I cut a hole for the display on the far left of the ammo can near the top to leave room on the right side for the bell. I used sprinkler tubing slit lengthwise to cover the exposed metal and provide a border for the display. The metal edges are very sharp – be careful! You should file them down after cutting or drilling to prevent slicing your fingers.
Step 7: Remote Control Menu System
Description of the 'menu' system:
- Upon initial power on of the timer, a lower case 'm' will display in the left 2 digits of the display.
- At this point there are three valid inputs from the remote control (press '1', '2', or '3'), then subsequent options below:
- Stopwatch function. Displays a number 1 in the right-most digit of the display
- press 'back' to return to the main menu
- press 'play' to start the stopwatch
- press 'stop' to stop the stopwatch
- press 'play' to start again
- press 'back' to return to the stopwatch menu
- press 'up' arrow to increment minutes (up to 99)
- press 'down' arrow to decrement minutes (down to 0)
- press 'enter' to set the minutes to countdown. 'SET' will be displayed in the display
- press 'play' to start the timer
- press 'stop' to stop the timer
- press 'play' to start again
- press 'back' to return to the timer menu
- press play to start the tabata timer
- press 'stop' to stop the tabata timer
- press 'play' to start again press 'back' to return to the tabata timer menu