Simple Countdown Timer Needed for App Inventor 2

8,235 views
Skip to first unread message

dwar...@allabouthope.org

unread,
Feb 20, 2014, 11:13:18 PM2/20/14
to mitappinv...@googlegroups.com
I'm looking for a way to include a countdown timer as part of my app. I want the user to input the minutes and seconds then have the timer display the countdown.

I looked through the forums, but couldn't find anything that does what I need.

This post works well, but only displays seconds, not minutes and seconds.
https://groups.google.com/forum/#!msg/mitappinventortest/jKUhX-1ubg0/IAabp5YpK9AJ

This post looks pretty close, but it's for App Inventor Classic and I can't for the life of me seem to translate it.
http://puravidaapps.com/countdown.php

I've included a screen shot of what I created, but it just doesn't work. The minutes don't coincide with the seconds and I have to use three different clocks. (One for the initial seconds inputed, one for each remaining 60 seconds, and one for the minutes.)

Help would be appreciated

countdown timer.png

SteveJG

unread,
Feb 21, 2014, 12:12:27 PM2/21/14
to mitappinv...@googlegroups.com, dwar...@allabouthope.org
Using three clocks may be unnecessary.   Keep in mind, the default clock setting is 1000.  The value is in milliseconds.  second =1000 milliseconds. Divide milliseconds by 1000 to obtain seconds.

Why not keep the counter in milliseconds?      If user wants "2 minutes, 1 second;" convert his input to 2 minutes/second  x 1000 ms/second   and use that value;    To report, reverse the process.  Let the timer report in ms to the global variable, then convert ms to minutes, seconds, etc in the label?  Did I understand you correctly?   Keep track of time in ms.    Convert what the user wants to ms.  As the clock reports the time, convert the ms to minutes seconds.


A suggestion.

Regards,
Steve

Taifun

unread,
Feb 21, 2014, 4:47:13 PM2/21/14
to mitappinv...@googlegroups.com, dwar...@allabouthope.org
This post looks pretty close, but it's for App Inventor Classic and I can't for the life of me seem to translate it.
http://puravidaapps.com/countdown.php

AI1 and AI2 is more or less the same and the few differences are explained here What's different?
hope that helps...
Taifun

dwar...@allabouthope.org

unread,
Feb 21, 2014, 5:39:48 PM2/21/14
to mitappinv...@googlegroups.com
Thanks guys for the feedback. I think I got it. I've attached a screen shot of what I have for future reference.
The biggest issue I had was trying to get single digit numbers like 1,2,or 3 to display as 01,02, or 03. I wound up using an if/then/else block to determine is the number is <10 and then a join block to add an extra 0 in front. (This is not included in the screen shot).

simple timer.png

David W

unread,
Jan 2, 2015, 10:01:40 PM1/2/15
to mitappinv...@googlegroups.com
Here's a more simplified version. It only requires a single timer. I use a list picker to choose the minutes and seconds.
countdown timer.jpg
Message has been deleted

Mihai Salajan

unread,
Mar 19, 2015, 10:02:24 AM3/19/15
to mitappinv...@googlegroups.com
Hello everybody
I am new in the branch so i need help obvious
I have created a program to control an arduino board and i need to include a countdown timer with 2 option
1: start countdown from 15 minutes 2: start countdown from 30 minutes but here is the tricky part i need to include 2 buttons 1: for + 5 minutes wich add 5 minutes to the routing time , and another wich drops 5 minutes from running timer

Abraham Getzler

unread,
Mar 19, 2015, 5:26:03 PM3/19/15
to mitappinv...@googlegroups.com
I think you can find better countdown clock examples in this board
than this thread.  Many people have asked this question.

Review all the blocks in the Clock component, especially the ones that 
convert Instants to milliseconds.

You will need to keep a global variable with the target Instant value
when you want the alarm to fire.

Your three buttons will set and up and lower that value.

Your Clock will continually display the milliseconds between Now() and your target,
converted to minutes and seconds the usual way.

ABG

Reply all
Reply to author
Forward
0 new messages