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

Note

On WRISTBAND_3, there is no ADC functionality available

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. If the pin is configured as ADC, the value returned will be between 0 and 1000, representing voltages from 0V to 3.3V (gpio.ADC is only available in 1.9+).

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.ADC

Configure pin as ADC 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.