delay

This is a discussion on delay within the C Programming forums, part of the General Programming Boards category; Hi I'm seraching for a tutorial where "delay" is explained. I have already looked up in serveral books but I ...

  1. #1
    Unregistered
    Guest

    Lightbulb delay

    Hi

    I'm seraching for a tutorial where "delay" is explained. I have already looked up in serveral books but I can`t find.

    thanks

    my e-mail: nickname007@uboot.com

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    The function delay is not part of ANSI C. But you can use the time functions to do something like that, or find a special function your compiler supports.

    http://www.acm.uiuc.edu/webmonkeys/book/c_guide/

  3. #3
    Registered User lliero's Avatar
    Join Date
    Oct 2001
    Posts
    59

    you

    you can delay a certain portion of your program
    by implementing a loop


    e.g

    myDelay(){
    for (i=0;i=100000;i++){ // this will delay for some time
    }
    }
    " programming is 1% syntax and 99% logic "

  4. #4
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    Note that lliero is machine dependent.

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >Note that lliero is machine dependent.
    Yes, depending on the processor speed of the machine running that code it will take more or less time to complete the loop. This function will work a bit more portably.
    Code:
    #include <time.h>
    
    void delay ( long n )
    {
      clock_t l, c = clock();
      for ( l = c + n; l > c; c = clock() );
    }
    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Regarding delay in the connection
    By byatin in forum Networking/Device Communication
    Replies: 2
    Last Post: 08-19-2008, 03:59 PM
  2. temperature sensors
    By danko in forum C Programming
    Replies: 22
    Last Post: 07-10-2007, 08:26 PM
  3. Networking (queuing delay, avg packet loss)
    By spoon_ in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 09-05-2005, 12:23 PM
  4. 2-3 Second delay with alarm()
    By Longie in forum C Programming
    Replies: 11
    Last Post: 06-20-2004, 09:46 PM
  5. Delay
    By CanadianOutlaw in forum C++ Programming
    Replies: 4
    Last Post: 09-13-2001, 07:28 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21