DigitalInputDevice

DigitalInputDevice

new DigitalInputDevice(pin, pull_upopt, bounce_timeopt)

Source:
Represents a generic input device with typical on/off behaviour. This class extends InputDevice with machinery to fire the active and inactive events for devices that operate in a typical digital manner straight forward on / off states with (reasonably) clean transitions between the two.
Parameters:
Name Type Attributes Description
pin int The GPIO pin (in Broadcom numbering) that the device is connected to.
pull_up boolean <optional>
If `true`, the pin will be pulled high with an internal resistor. If `false` (the default), the pin will be pulled low.
bounce_time float <optional>
Specifies the length of time (in seconds) that the component will ignore changes in state after an initial change. This defaults to `undefined` which indicates that no bounce compensation will be performed.

Extends

Methods

close()

Source:
Inherited From:
Close the device and remove the pin allocation allowing it to be reused.

closed() → {boolean}

Source:
Inherited From:
Returns:
- Is ``true`` is no pin is allocated.
Type
boolean

is_active() → {boolean}

Source:
Inherited From:
Returns:
- Is true is the device value is currently set.
Type
boolean

pin() → {undefined|*|int|Pin}

Source:
Inherited From:
Returns:
- The Pin that the device is connected to. This will be ``undefined`` if the device has been closed (see the :meth:`close` method). When dealing with GPIO pins, query ``pin.number`` to discover the GPIO pin (in BCM numbering) that the device is connected to.
Type
undefined | * | int | Pin

pull_up()

Source:
Inherited From:
If ``true``, the device uses a pull-up resistor to set the GPIO pin "high" by default.

toString() → {string}

Source:
Inherited From:
Returns:
- Description of the device.
Type
string

value() → {int|Boolean}

Source:
Inherited From:
Returns:
- Current value of the pin.
Type
int | Boolean