When you use the following code to generate digital pulses with the Arduino Uno (cli()
and sei()
and to disable and enalbe interrupts in order to ensure consistent pulse width):
cli(); digitalWrite(outputPin, HIGH); digitalWrite(outputPin, LOW); sei();
the time it takes to digitalWrite()
dominates. Based on the 16 MHz clock frequency of the ATMega328p, this generates pulses exactly 4 microseconds in length: