Redundant calls to digitalWrite()

If I make a redundant call to digitalWrite() does it have any effect on the output? For example:

while(true)
  digitalWrite(pinNum, HIGH);
while(true)
  if (digitalRead(pinNum) != HIGH)
    digitalWrite(pinNum, HIGH);

Electrically, is there a difference between these two code snippets? For example, does the output waver or stutter at all when the digitalWrite is called?

joshuabardwell:
If I make a redundant call to digitalWrite() does it have any effect on the output?

No.

Electrically, is there a difference between these two code snippets?

No.

For example, does the output waver or stutter at all when the digitalWrite is called?

No.

Ok, thanks.

and if the pin is an input? ]:slight_smile:

robtillaart:
and if the pin is an input? ]:slight_smile:

DigitalWrite to an input pin enables or disables the pullup resistor.

but this line makes it conditional

  • if (digitalRead(pinNum) != HIGH) ...

so electrical there could be a difference

robtillaart:
but this line makes it conditional

  • if (digitalRead(pinNum) != HIGH) ...

so electrical there could be a difference

This was the point of the original question, though. And the answer is that setting an I/O pin to the same state that it has already been set to does not make any difference apart from using a few CPU cycles.