Configure GPIO

This python code example demonstrates the following:

  • Connection to a PiMotion device
  • Configuration of the GPIO direction
  • Write to and readback from a pin

[source code]

import pilib

pm = pilib.Pidev('192.168.1.200')        # make a connection to the PiMotion

pm.gpio_set_direction(0xff, 0b01111111)  # gpio 7 is output, all others input
pm.gpio_set_value(0xff, 0b10000000)      # gpio 7 output set high

print (bin(pm.gpio_get_value(0b11111111))) # read and print values from all gpio

Output:

0b10000000