digitalRead() from pins greater than number of pins on board

Occasionally I see:

define WIFLY_GPIO6 76

int i = digitalRead(WIFLY_GPIO6);

or something similar, where digitalRead's parameter is not a "real" pin number.

These lines are from a library designed to communicate with a RovingNetworks Wifly module, it is connected to the Arduino only via pins 10 and 11 and communicates with SoftwareSerial.

What's going on here? What use are pin numbers greater than the number of pins on the Arduino?

Thanks, -w

  1. The analog pins, used in digital mode, are numbered past the end of the digital pins. So digitalRead(14) on an Uno returns the digital state of Analog pin 0.
  2. Sometimes, pins that are not available on connectors are still on the board somewhat, doing possibly useful things. For example, on Leonardo a user sketch can manipulate the RX and TX LEDs.
  3. There is no error checking, and programs have been known to have bugs.

Thanks for the quick reply,

Must be some kind of leftover from testing the library. A digitalRead from this pin always seems to be 0, and the WiFly GPIO6 pin is not actually connected to anything according to the schematic of the shield.

BTW here is great tutorial for our readers on how all the pin mapping macros work:

http://urbanhonking.com/ideasfordozens/2009/05/18/an_tour_of_the_arduino_interna/

The shield is the Seeed WiFi1.1 - it’s essentially a Roving Networks RN171 proto board, which is great little module with lots of interesting capabilites.

You will get more pins on a Mega that a UNO. The "not real" pin number as you call it is when a pin number is a variable.