Thanks Michael and Digistump
Michael you appear to be correct in that specifying "A0" will take an analog reading from P5, and allow P0 to be used as a digital output.
For example:
const int RangePin = A0; // Rangefinder input pin
const int Motor = 0 //Motor output via transistor
void setup() {
pinMode(RangePin, INPUT);
pinMode(Motor, OUTPUT);
}
void loop() {
if (analogRead(RangePin) > 50) {
digitalWrite(Motor, HIGH);
}
else {
digitalWrite(Motor, LOW);
}
}
appears to work. Can't be sure without some more trials, but I also see, reading the Wiki further, that analogRead(3) does actually ready from physical P3, so as long as I only need one analog pin, I'll probably use 3 since there's no confusion.
I haven't tried it without the "A", as Digistump says. Seems dicey, calling out the same "pin" for two different things, but if it works, it works.
Woot!