View Full Version : Delay Function for C Program
02-16-2005, 12:18 AM
Currently, my program is using "sleep(1)" to delay the rotation of LED. This mean that it's rotating at 1 sec interval.
Is there any delay function which i can implement so that i can rotate the LED at a faster rate??
Thanks in advance
You probably want to use usleep(microseconds)
02-19-2005, 03:35 PM
In C Programming both Sleep(), sleep(), and SleepEx() all pause for milliseconds. Not seconds. So your code should be working fine unless I missed something.
Sleep() and SleepEx() are windows functions which wait for milliseconds, while sleep() is a linux function which waits for seconds.
Since he used sleep() in his example and not Sleep(), I gave him a linux function he can use to get a lower wait time than 1 second.
03-23-2005, 05:35 PM
:D Sorry to mislead you West_dweller79.....
For some reason sleep() does not work in m projects. VC++ 6.0 on WinXP SP1. It shows up in MSDN but I don't see any libraries or headers to include to work it. :confused: :confused:
For windows sleep() is undefined, as I posted earlier it's used in alot of linux distributions.
You should #include <windows.h> and use Sleep(ms).
An alternative would be to #include <stdlib.h> and use _sleep(ms) if it's available for your compiler.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.