gpio
- GPIO Pins¶
The gpio
module allows you to use card10’s GPIO pins as input and
output in your scripts.
Example:
import gpio
gpio.set_mode(gpio.WRISTBAND_1, gpio.mode.OUTPUT)
gpio.write(gpio.WRISTBAND_1, True)
gpio.set_mode(gpio.WRISTBAND_2, gpio.mode.INPUT | gpio.mode.PULL_UP)
state = gpio.read(gpio.WRISTBAND_2)
print("State of Wristband pin 2:", state)
-
gpio.
set_mode
(pin, mode)¶ Configure GPIO pin state.
- Parameters
pin (int) – ID of the pin to be configured.
mode (int) – An integer with the bits for the wanted mode set. Create your integer by ORing
gpio.mode.OUTPUT
,gpio.mode.INPUT
,gpio.mode.PULL_UP
,gpio.mode.PULL_DOWN
.
-
gpio.
get_mode
(pin)¶ Get GPIO pin state.
- Parameters
pin (int) – ID of the pin of to get the mode of.
- Returns
An integer with the configure mode bits set.
-
gpio.
write
(pin, value)¶ Write a value to a GPIO pin.
- Parameters
pin (int) – ID of the pin of to get the mode of.
value (bool) – New pin value.
-
gpio.
read
(pin)¶ Read GPIO pin value.
- Parameters
pin (int) – ID of the pin of to get the mode of.
- Returns
Current value of the GPIO pin.
-
gpio.
WRISTBAND_1
¶ Pin ID for Wristband GPIO 1.
-
gpio.
WRISTBAND_2
¶ Pin ID for Wristband GPIO 2.
-
gpio.
WRISTBAND_3
¶ Pin ID for Wristband GPIO 3.
-
gpio.
WRISTBAND_4
¶ Pin ID for Wristband GPIO 4.
-
gpio.mode.
OUTPUT
¶ Configures a pin as output.
-
gpio.mode.
INPUT
¶ Configures a pin as input.
-
gpio.mode.
PULL_UP
¶ Enables the internal pull-up resistor of a pin.
-
gpio.mode.
PULL_DOWN
¶ Enables the internal pull-down resistor of a pin.