Delay Function In Dev C

Delay in C: delay function is used to suspend execution of a program for a particular time.

Which of the following delay commands causes the Arduino program to delay 1.5 seconds? A) delay(1.5) b) delay(15) c) delay(150) d) delay(1500) For an Arduino C program, which one of the following is the initial value of 100, a variable named duration is defined correctly? Delay Function In Dev C This method depends on the system clock. This means that the time delay will approximately equal the resolution of the system clock if the delay argument is less than the resolution of the system clock, which is approximately 15 milliseconds on Windows systems. Visual C Delay Function.

Declaration: void delay(unsigned int);

Here unsigned int is the number of milliseconds (remember 1 second = 1000 milliseconds). To use delay function in your program you should include the 'dos.h' header file which is not a part of standard C library.

Delay in C program

Delay Function In Dev Circuit

If you don't wish to use delay function then you can use loops to produce delay in a C program.

#include<stdio.h>

int main()
{
int c, d;
for(c =1; c <=32767; c++)
for(d =1; d <=32767; d++)
{}
return0;
}

We have not written any statement in the loop body. You may write some statements that doesn't affect logic of the program.

C programming code for delay

#include<stdio.h>
#include<stdlib.h>

main()
{
printf('This C program will exit in 10 seconds.n');

delay(10000);

Dev

return0;
}

This C program exits in ten seconds, after the printf function is executed the program waits for 10000 milliseconds or 10 seconds and then it terminates.

Hi

I'm trying to use the outportb() function to send a signal to a RS-232 serial port. I understand that in order to use the function I need to #include <dos.h> and <conio.h>.

I am using Dev-C++ as my compiler and am having no luck when compiling the code. I am told that the function is undefined. My code is as follows (I am trying to send '2' on port '0x3FC':

I am very new to C++ though so may be missing something obvious. The only error message I receive is '`outportb' undeclared (first use this function)'.

Any help would be appreciated; for now I am simply trying to send the signal down the port. The device I have attached to the port is an LED which should light up when the signal is successfully sent.

  • 3 Contributors
  • forum6 Replies
  • 2,552 Views
  • 4 Days Discussion Span
  • commentLatest PostLatest Postby CaptainProg

Recommended Answers

Those sorts of low-level direct I/O calls (in the spirit of inp()/outp()) no longer work under Windows (as of NT and later) without a special device driver.

For an alternative look into the Win32 API functions like CreateFile.

See

FunctionJump to Post

You will also need to explicitly instruct Windows to associate your port with a COM device. You can find instructions '>here.

Finally, you would be aware that only 'COM1' through 'COM9' are …

FunctionJump to Post

All 6 Replies

jonsca1,059Quantitative Phrenologist Team ColleagueFeatured Poster

Those sorts of low-level direct I/O calls (in the spirit of inp()/outp()) no longer work under Windows (as of NT and later) without a special device driver.

Delay Function In Dev C++

For an alternative look into the Win32 API functions like CreateFile.

Delay Function In Dev Code

See this PDF as the author seems to go through those functions step by step.