Part 2: Simple Stopwatch
Another request we often hear is that users want to create a stopwatch so that they can keep track of sports like running or cycling. Part 2 of the Tempus app includes a simple stopwatch that you can include in your own projects.
Click to remix the “Tempus” app
Components
In this example I’ve used a label to display the elapsed time and two buttons. One button is to start/stop the stopwatch and the other is to reset the timer.
Don’t forget to include a Timer component too, as it keeps track of time for us. Use the following settings if you want your app to work the same as mine:
Incrementer
Start by creating a local variable to keep track of how long the stopwatch has been running for. I’ve called my variable time
but you can call it whatever you like.
When the timer is running we increase the value by 1 seconds and display this new value in the label.
Reset
When the reset button is clicked we zero the timer and display the new value in the label.
Start/Stop
Finally a simple toggle is used to start and stop the timer.
To learn more about creating your own toggle buttons, take a look at the sample app “Toggl”
Your turn
If you want to use this app as a reference then you can create your own copy by clicking on the link below