2

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

Marwynne
  • 21
  • 1
  • 2
    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) – Chris Stratton Dec 28 '11 at 16:42
  • @ChrisStratton Sounds like you have enough there to turn it in to an answer. – Kellenjb Dec 28 '11 at 16:49
  • This question can probably help you: http://electronics.stackexchange.com/questions/22584/arduino-better-microsecond-resolution-than-micros – Kellenjb Dec 28 '11 at 16:51
  • @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. – Chris Stratton Dec 28 '11 at 16:54
  • @ChrisStratton Fair enough – Kellenjb Dec 28 '11 at 16:55
  • Not sure if you have checked delayMicroseconds() in the Arduino reference. – bdutta74 Dec 28 '11 at 19:31

1 Answers1

1

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."

Majenko
  • 55,955
  • 9
  • 105
  • 187