aboutsummaryrefslogtreecommitdiffstats
path: root/source/arduino/delaymicroseconds.rst
blob: 0feaba7ac880638917b9bcdc60cff16cd72c99db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
.. _arduino-delaymicroseconds:

delayMicroseconds()
===================

Description
-----------

Pauses the program for the amount of time (in microseconds)
specified as parameter. There are a thousand microseconds in a
millisecond, and a million microseconds in a second.



Currently, the largest value that will produce an accurate delay is
16383. This could change in future Arduino releases. For delays
longer than a few thousand microseconds, you should use delay()
instead.



Syntax
------

delayMicroseconds(us)



Parameters
----------

us: the number of microseconds to pause (*unsigned int*)



Returns
-------

None



Example
-------

::

     
    int outPin = 8;                 // digital pin 8
    
    void setup()
    {
      pinMode(outPin, OUTPUT);      // sets the digital pin as output
    }
    
    void loop()
    {
      digitalWrite(outPin, HIGH);   // sets the pin on
      delayMicroseconds(50);        // pauses for 50 microseconds      
      digitalWrite(outPin, LOW);    // sets the pin off
      delayMicroseconds(50);        // pauses for 50 microseconds      
    }



configures pin number 8 to work as an output pin. It sends a train
of pulses with 100 microseconds period.



Caveats and Known Issues
------------------------

This function works very accurately in the range 3 microseconds and
up. We cannot assure that delayMicroseconds will perform precisely
for smaller delay-times.



As of Arduino 0018, delayMicroseconds() no longer disables
interrupts.



See also
--------


-  `millis <http://arduino.cc/en/Reference/Millis>`_\ ()
-  `micros <http://arduino.cc/en/Reference/Micros>`_\ ()
-  `delay <http://arduino.cc/en/Reference/Delay>`_\ ()