Newbie question! How do I change the pulse duration of a digital output from the board? Are there any limits to this? What dictates the minimum gap between a series of such outputs?
Thanks.
How do I change the pulse duration of a digital output from the board
Put a delay/delayMicroseconds between writing the two states of the pulse:
digitalWrite(pulsePin, HIGH);
delay (pulseWidthHigh);
digitalWrite(pulsePin, LOW);
delay (pulseWidthLow);
Or similar - what do you want to do?
There is no limit to the length of the pulse, but watch out for timer wrap-around for very long delays.
The clock speed of the chip and overheads in calling the output functions are the limiting factors in pulse rate.
Awol, thanks a lot for your response.
How do you define a pulse duration of less than a millisecond (does delay allow value less than one?)?
My application is fairly simple. I am looking to output out a train of TTL outputs with a defined pulse width and frequency in order to trigger an external device. This device has a serial input so I assume I need to look at the tutorials I have seen on the Arduino site about this aspect. Is that correct?
Thanks
delayMicroseconds - read the reference to check that it will do the sort of pulse length you need.
Thanks for the response.
And regarding the control, from a series TTL pulses produced by the board, of a serial port attached to another device, is that something simple to do if I follow the steps described in the various tutorials on the site?
For custom PWM setups I recommend the "Compare Match Output Unit" section in the atmega datasheet (Fast PWM Mode for Timer/Counter 1).