using digitalWrite() on a non existing pin

Hi,

simple and short question (I didn’t find any answer with goolge…):
What happens, if I try to set the status of a not existing pin, i.e. digitalWrite(99,HIGH) ?

Has anyone ever tried? At least I get no compiler errors…

Why would you expect compiler errors?
If you want to know, why not look at the source?

I've accidentally done that, and nothing happened.

and nothing happened

Oh but something did happen! There just weren't any noticeable side-affects.

Kind of like if a tree falls in the forest with nobody around did it really make a noise? :wink:

Lefty

Oh but something did happen! There just weren't any noticeable side-affects

There may well have been side-effects.
The "digitalPinToPort", "digitalPinToBitMask" and "digitalPinToPort" are all macros without any bounds checking on the arrays they access.
They could pick up any old rubbish from program memory and interpret it as valid port and pin information.

They could pick up any old rubbish from program memory and interpret it as valid port and pin information.

Worse than that, since the ports/pins are just bits in registers in the AVR “memory space” that is occupied by data memory and other peripheral registers. a digitalWrite() could theoretically set a random bit in a random location, causing truly weird program behavior or subtly changing the AVR’s behavior in bad ways…