PDA

View Full Version : Out of range pin numbers - do they do anything bad?



Dozer
11-16-2012, 07:04 AM
If I do this:

pinMode(100, OUTPUT);
or

digitalWrite(-1, HIGH);
does anything bad happen? It appears to work fine.

PaulStoffregen
11-16-2012, 09:07 AM
On Teensy, these functions do nothing when an out-of-range pin number is used.

If your program might ever be used on an official Arduino board, or some non-Teensy board that uses the core library published by Arduino, you might want to avoid this. Arduino's code does not properly check for out-of-range pin numbers.

Dozer
11-16-2012, 09:25 AM
Great! These are for my X-Plane interfacing classes, so it's very unlikely they'll be portable to Arduino without a struggle anyway. I'll put a note in the source to inform future generations to add a slew of new class constructors if they want to try anything like that.