Skip to content
alexanderhiam edited this page Nov 6, 2012 · 4 revisions

The simplest functionality that PyBBIO provides access to is the GPIO, or General Purpose Input/Output, module. When the external pins connected to this module are configured as outputs they may be set to either a high or low level, which on the BeagleBone means 3.3v or 0v respectively. When configured as inputs the state of the pins may be read as either high or low, where high > ~1.5v > low.

Applying voltages greater than 3.3v to the GPIO pins can cause permanent damage to your BeagleBone!


###Example programs:
PyBBIO/examples/blink.py
PyBBIO/examples/digitalRead.py
PyBBIO/examples/switch.py


###Constants:
INPUT - For configuring pin direction; equal to 1.
OUTPUT - For configuring pin direction; equal to 0.
HIGH - High state for reading/writing pins; equal to 1.
LOW - Low state for reading/writing pins; equal to 0.


###Functions:
#####pinMode(gpio_pin, direction, pull=0)
Sets the direction of the given digital pin as either INPUT or OUTPUT. The optional 'pull' argument can be used to set either a pull-up or pull-down resistor on the pin if setting it as an input: pull = -1 for a pull-down, pull = 1 for a pull-up, and the default of pull = 0 for neither.

#####digitalWrite(gpio_pin, state)
Sets the state of the given digital pin to either HIGH or LOW. The pin should already be configured as an output.

#####toggle(gpio_pin)
Sets the state of the given digital pin to the opposite of its current state. The pin should already be configured as an output.

#####digitalRead(gpio_pin)
Reads and returns the state of the given digital pin as either HIGH or LOW. The pin should already be configured as an input.

#####pinState(digital_pin)
Returns the current state of a the given digital pin if it is configured as an output, or None if it is configured as an input.


###Available GPIO pins: Pins listed in form:

Location - function
Where **function** is also the name of PyBBIO's corresponding constant.

#####Header P8:

P8.3  - GPIO1_6
P8.4  - GPIO1_7
P8.5  - GPIO1_2
P8.6  - GPIO1_3
P8.11 - GPIO1_13
P8.12 - GPIO1_12
P8.14 - GPIO0_26
P8.15 - GPIO1_15
P8.16 - GPIO1_14
P8.17 - GPIO0_27
P8.18 - GPIO2_1
P8.20 - GPIO1_31
P8.21 - GPIO1_30
P8.22 - GPIO1_5
P8.23 - GPIO1_4
P8.24 - GPIO1_1
P8.25 - GPIO1_0
P8.26 - GPIO1_29
P8.27 - GPIO2_22
P8.28 - GPIO2_24
P8.29 - GPIO2_23
P8.30 - GPIO2_25
P8.39 - GPIO2_12
P8.40 - GPIO2_13
P8.41 - GPIO2_10
P8.42 - GPIO2_11
P8.43 - GPIO2_8
P8.44 - GPIO2_9
P8.45 - GPIO2_6
P8.46 - GPIO2_7

#####Header P9:

P9.12 - GPIO1_28
P9.15 - GPIO1_16
P9.23 - GPIO1_17
P9.25 - GPIO3_21
P9.27 - GPIO3_19
P9.42 - GPIO0_7

#####On-board LEDs: These are found next to the Ethernet jack and are labeled with the same names.

USR0
USR1
USR2
USR3
Note that the **USR0** LED is used as a system status output on the default Angstrom image, so it's probably not that useful.
Clone this wiki locally