Is it bad form to set a digital output to the same value over and over again.

Hey guys, newby question.

So, I am wondering if it is bad form or perfectly okay to set a digital output to the same value over and over again if nothing changed. For example, if I had something like this:

void loop() {

    if (isThingOn()) {
        digitalWrite(ledPin, HIGH);
    }

}

So in this case, assuming isThingOn() is true, on every iteration I would be setting the ledPin HIGH. Since it was already high, nothing changes and it just keeps the LED on. Is this proper, or is there any downside that would make it desirable to only change the output if the value is different than the one already in use?

Thanks.

Meh. It's harmless but it wastes time if you're worried about speed.

There is nothing wrong with writing a state to the pin over and over. You will not wear the pin out or harm anything.

It is perfectly OK to set the state of a pin as often and as many times as you want, if a little inelegant

One exception: there is a bug in digitalWrite() for the Nano 33 BLE boards, which causes a square wave when you set the pin to the same state repeatedly.

This is only relevant if you're using a Nano 33 BLE or Nano 33 BLE Sense.

Good information. Thank you all.