Thread: help - timer in C?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    2

    help - timer in C?

    Hi guys. Sorry if this is a regularly posted question, but here goes:

    We're currently working on a project for a class based on C programming. Last term, we did the same class, but with MatLab. (I'm not sure if you guys are familiar with the software)

    The project that we're assigned this term is to power two 7-segment LED's to reflect elapsed time in seconds. We've searched around, and found "time.h" and the "clock_t" function, but it seems that it only keeps track of time in full seconds? Also, it doesn't seem to have the functionality that we are looking for - we can calculate the difference in time via "difftime(t2-t1)", but in order for this to work effectively, we must calculate the difference constantly.

    Right now, we've got a good idea of what the code should look like, but as you can see, we keep running into a wall in regards to measuring time.

    The reason I brought up MatLab earlier in the post is because there's a function called tic toc. "tic" starts a timer in MatLab, while "toc" returns a time value since the intial "tic". Is there something in C that is similar to this?

    for example, for our last term's project, we did the following:
    Code:
    <headers, blah blah blah blah etc>
    tic
    
    while (toc < [set time values])
    {
    do stuff
    }
    etc
    Thanks for the help!
    Last edited by psu_ece; 05-15-2010 at 12:58 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. hi-res vs. normal timer
    By MK27 in forum C Programming
    Replies: 0
    Last Post: 12-02-2009, 08:53 PM
  2. SIGALRM and timer
    By nkhambal in forum C Programming
    Replies: 1
    Last Post: 06-30-2008, 12:23 AM
  3. tic tac toe crashes :(
    By stien in forum Game Programming
    Replies: 4
    Last Post: 05-13-2007, 06:25 PM
  4. Need help with a count down timer
    By GUIPenguin in forum C# Programming
    Replies: 0
    Last Post: 07-07-2006, 04:18 PM