The Pin class represents a physical pin on the imp card or module.
imp001 cards have six versatile IO pins, each with a corresponding pin object, named after their positions on the imp connector: pin1, pin2, pin5, pin7, pin8 and pin9.
imp002 modules add a further six pins — pin6 and pinA through pinE — see the imp002 pin mux documentation for full details.
imp003 modules (Murata part number LBWA1ZV1CD) have 23 pins in total. However, these pins’ designations are entirely different from those of the imp001 and imp002. Again, see the imp003 pin mux documentation for a full listing of imp003 pins.
imp004m modules (Murata part number LBEE5ZZ1MD) have 18 GPIO pins. These pins’ designations follow the naming scheme employed for the imp003, but there is not a 1:1 mapping of pin functionality between the two modules. See the imp004m pin mux documentation for a full listing of imp004m pins.
imp005 modules (Murata part number LBWA1UZ1GC-901) have 28 GPIO pins in total. These pins’ designations follow the naming scheme employed for the imp003. Instead of pin X, the imp005 has pins XA through XE. See the imp005 pin mux for full details.
Note The imp005 requires impOS™ 36 to support Pulse-Width Modulation (PWM) functionality through its GPIO pins.
impC001 modules have 44 GPIO pins in total. These pins’ designations follow the naming scheme employed for the imp003. Instead of pin X, the impC001 has pins XA through XD, and in place of pin Y, pins YA through YU. See the impC001 pin mux for full details.
Note The impC001 currently lacks support for pulse counter and pin-triggered pulse generation (PTPG) through its GPIO pins.
Each pin can be used as a GPIO — a digital input or digital output — and many have further available modes such as PWM output or analog input (ADC). Not all modes are available on every pin. On the imp001, for instance, pins 1 and/or 5 can alternatively be used as analog outputs (DAC); pin 1 can alternatively be used as a pulse-counter or as a wake-up from low-power modes. See the imp pin mux to learn exactly what facilities are available on each pin.
The ADCs return a number which represents the analog voltage sampled; the lowest number they can return is zero, representing 0V, and the highest is 65535, which represents the supply voltage. This number doesn’t directly map to a voltage. For example, say you apply 1.5V to a pin and read this. If your chip is supplied at 3.0V, then you would read:
(1.5 / 3.0) * 65535 = 32767
However, with the same 1.5V pin voltage and a 3.3V supply voltage you would read:
(1.5 / 3.3) * 65535 = 29788
To work out the actual voltage of a pin, you first use hardware.voltage(), which internally reads a known reference (fixed) voltage with the ADC and uses that reading to determine what the actual supply voltage of the chip is, which it then returns. You then scale this by the number you read, as whatever voltage is on your pin as a fraction of the supply.
The pin objects are instantiated at start-up, and are accessed through the hardware object, for example:
ledPin <- hardware.pin1;
To unconfigure a pin if it is no longer required, use
pin.configure(DIGITAL_IN), which has the effect of tri-stating the pin.
The pin object has the following member methods: