2
\$\begingroup\$

I am building a project that requires the pin output for 160 micro seconds. I will need to delay for 10 microseconds and turn on a sec output pin for 30-40 micro seconds.

I can not find any information on turning on a digital output pin for micro seconds. I can find it for miliseconds.

Your assistance is apprecitated

Marwynne

\$\endgroup\$
6
  • 2
    \$\begingroup\$ At those time scales, my personal preference would be to ditch the Arduino layers and write plain avr-gcc code so that everything running on the chip which could potentially interfere would be plainly visible in my source files. The task could then be done with either a delay loop or timer interrupts. I expect however it can be done within Arduino by similar methods, after suppressing any serial, etc interrupts that might get in the way (or if its okay if your timing is occasionally erratic) \$\endgroup\$ Commented Dec 28, 2011 at 16:42
  • \$\begingroup\$ @ChrisStratton Sounds like you have enough there to turn it in to an answer. \$\endgroup\$
    – Kellenjb
    Commented Dec 28, 2011 at 16:49
  • \$\begingroup\$ This question can probably help you: electronics.stackexchange.com/questions/22584/… \$\endgroup\$
    – Kellenjb
    Commented Dec 28, 2011 at 16:51
  • \$\begingroup\$ @Kellenjb not ruling that out but was intending it more as brief initial advice. And even though I'd be disinclined to do so, I'm curious if anyone knows how to reliably do it on top of the Arduino layers. I should mention that avr-gcc code can generally be loaded into the chip using the arduino bootloader, so one can switch back and forth between that and sketches quite easily. \$\endgroup\$ Commented Dec 28, 2011 at 16:54
  • \$\begingroup\$ @ChrisStratton Fair enough \$\endgroup\$
    – Kellenjb
    Commented Dec 28, 2011 at 16:55

1 Answer 1

1
\$\begingroup\$

You should take a look at the TimerOne library.

Using this you can trigger events at specific intervals with a pretty high resolution of clock - higher than using the simple delay() functions.

"... The minimum period or highest frequency this library supports is 1 microsecond or 1 MHz."

\$\endgroup\$
2
  • \$\begingroup\$ Any idea how this prioritizes compared to other interrupts implicit in the Arduino stuff? \$\endgroup\$ Commented Dec 28, 2011 at 17:04
  • \$\begingroup\$ None whatsoever ;) Does the Atmel even have interrupt priorities? \$\endgroup\$
    – Majenko
    Commented Dec 28, 2011 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.