# minimum delay

Is it possible to set two or more pins to HIGH at the same time ? for example

digitalWrite(3, HIGH); digitalWrite(4, HIGH);

can I assume pin 3 and 4 are set to high at the same time, with delay=0 or I have to take into account a delay of 62.5 ns ?

thanks

Check out "port manipulation." With that you can get two pins on the same port to change at exactly the same time. If they're on different ports, they will have a small delay on the order of a few clock cycles. With digitalWrite, it takes time on the order of a microsecond.

softuino: or I have to take into account a delay of 62.5 ns ?

Whether or not you have to account for the delay depends entirely on what you are doing with these pins.

this is what I am doing with these pins: output exactly at the same time, no time delay delay=0

I don't want a delay of 2 or 3 microseconds, neither nanoseconds, nothing, delay=0

The question was, is it strictly necessary for them to output at the same time (i.e. what is the intended purpose).

You can get the to output with a delay of 0 between each, but only if they are on the same Port (e.g. portA, PortB, PortC etc), and not using digital write. http://www.arduino.cc/en/Reference/PortManipulation

softuino: I don't want a delay of 2 or 3 microseconds, neither nanoseconds, nothing, delay=0

You do know that's impossible, right? It takes a relatively long time for the signal to go from HIGH to LOW depending on the capacitance and that will be affected by all sorts of noise at the nanosecond scale.

ok, that's all I wanted to know (first question...)

thanks

I think what Wizened was saying is it is simply impossible for any device to raise a voltage level in 0 time. In any square wave, the signal takes some time to go from 0 to x. The sides of the square wave are never truly vertical. It has nothing to do with Arduino, it's a physical reality.

Why don't you tell us what you're trying to do and we can help you out more?

softuino: I don't want a delay of 2 or 3 microseconds, neither nanoseconds, nothing, delay=0

A delay of zero is physically impossible, and it is physically impossible for any external device or circuit to detect whether you have achieved it. Since this is not a credible requirement, you ought to be more precise about what you're actually trying to achieve. How small a timing difference are you aiming for?

I think I’ve just found the only thing faster than Arduino …

It’s … the Phelpsduino!
Congrats to all USA athletes. You’re doing well!

I think, IMHO, you’ll get the closest or equal to zero delay by accessing the port registers.

Is it just “Curiosity” (don’t forget to watch the landing on August 5th) or are you timing some important competition sport events, or horse racings or similar things, or is it just a matter for theoretical discussion?

As an extension to this problem, if you or’ed the bits in they would hit as close to the same time as possible for the register, no? What if you shift the bits in? Would the bit ripple across the output reg?

Jerry

When the output register is written to, the pins change.

I think the OP needs to explain the “real” problem. Nothing happens in zero time. Even electrons take a finite time to fly around the nucleus.

softuino: output exactly at the same time, no time delay delay=0

I don't want a delay of 2 or 3 microseconds, neither nanoseconds, nothing, delay=0

I don't want to wax too deeply philosophical here, but for something to change in 0 nanoseconds, picoseconds or whatever, is impossible. Let's say that in the time interval "t" where t is zero, the outputs change. Then at that time they are both HIGH and LOW, which is impossible.

I think the OP needs to explain the "real" problem. Nothing happens in zero time. Even electrons take a finite time to fly around the nucleus.

Is it possible to set two or more pins to HIGH at the same time ?

The simple answer "yes, if they are on the same port; no, if they are on different ports." And "yes, if you write a byte to that port; no, if you use Arduino IDE"

.. was given immediately and the OP confirmed that his question was answered ;)

Another thing to keep in mind, children: Digital computing IS SLOW by its nature. ( Nowadays my TV takes longer to start than 50 years ago, when it had to heat up valves. )

“yes, if you write a byte to that port; no, if you use Arduino IDE”

But certainly one can use the Arduino IDE to write sketches that utilize direct port commands? That’s probably not what you meant.

Lefty

That's probably not what you meant.

Yes, no, that's not what I meant, sorry.

In the Arduino IDE you can click for help and find `digitalWrite(pin, value);` which is for a single pin only and will expose a measurable delay until the next pin changes. Of course you can enter `PORTB |= 0x003;` in the Arduino IDE, and compile it successfully there, too.