Reads the state of the specified pin
Device
Integer — the state of the specified pin
This method reads the state of the specified pin, according to its configured mode.
Digital inputs return a 0 or 1.
All non-analog uses of pin.read() will return the actual state of the pin even if it is configured for output — see the Digital Output example below, I²C, SPI and UART.
Analog inputs return values in the range 0-65,535 (16 bits), where 0 corresponds to 0V, and 65,535 corresponds to the imp power supply voltage, usually 3.3V.
The current ADC in the imp is only accurate to 12-bits. The value is returned as a 16-bit number to accommodate the possibility of more accurate ADCs being incorporated into future releases of the imp.
Pulse counters return the number of pulses counted over the requested time interval.
Pulse counting is synchronous (blocking). When counting pulses for 0.5 seconds, the pin.read() call will take 0.5 seconds to execute.
Reading a digital input
Polling an analog input
Reading a pulse counter
Reading a digital output