PYNQ Input/Output (I/O)
The PYNQ board has a number of sensors (buttons, switches) and actuators (LEDs), as well as a number of general-purpose input/output (I/O) (GPIO) pins. The hardware I/O pins include the Raspberry PI and Arduino headers.

- The 4 green LEDs (LD0..LED3) and 2 color LEDs (LD4-5R/G/B) are output pins. Note however that these LEDs are hidden behind the connectivity board.
- The buttons (BTN0..BTN3) and switches (SW0..SW1) are input pins. The buttons are exposed on the outside of the robot enclosure; the switches are not.
- The Arduino header contains 14 digital I/O pins (AR0..AR13) that can be individually set to input or output, as well as 6 analog input pins (A0..A5). AR4-AR13 are passed through the connectivity board and exposed on a header of that board. AR0-AR3 are not.
Two I/O pins (AR_SCL and AR_SDA) are pins for the I2C (Inter-Integrated Circuit) protocol. The are exposed on the connectivity board header as
!SCLand!SDA, respectively. - The Raspberry PI header contains 26 I/O pins that can be individually set to input or output. (Some of the pins are hardwired to ground or are not connected, and cannot be routed to/from the switchbox.) The Raspberry Pi header is not accessible via the connectivity board.
Arduino header
For the purposes of this course only the arduino header will be used, via the connectivity board, in the format displayed below:

See pinmap.h in the libpynq documentation for the Arduino pins (IO_A* and IO_AR*).
See Section 17 in the pynq user documentation for more information.
Switchbox
The 5AID0 SD-card image contains a switchbox that can be programmed to connect components on the PYNQ board to the hardware input/output pins on the PYNQ board.

Connecting the Robot Sensors
- the I2C pins
!SCL(clock) and!SDA(data) should be connected to the corresponding pins of the Time-of-Flight sensor. - the
AR8GPIO pin should be connected to the data line of the LED bar (it uses the one-wire protocol to control the LED colors). It will be connected to programmable logic that continuously sends the data - the 4 pins
AR9-AR12are used by the camera. The are controlled from the SPI communication module in the programmable logic of the PYNQAR9is connected to theSCLK(clock) pin of the camera (white wire)AR10is connected to theMISO(Master In Slave Out) pin of the camera (brown wire)AR11is connected to theMOSI(Master Out Slave In) pin of the camera (yellow wire)AR12is connected to theCS(chip select) pin of the camera (orange wire)
- the 4 pins
AR4-AR7are used for the digital signals of the line-follow sensors. - The sensors and LED bar are powered by 3.3V taken from the
3V3andGNDpins. They can be distributed using the+and-rails on the bread board on the connectivity board.
pinmap.h in the libpynq documentation describes which I/O pins are available as input or output to the switchbox.
switchbox.h in the libpynq documentation describes which hardware modules are available as input or output to the switchbox.
The switchbox can be programmed to set the status of I/O pins to input or output, and to connect the devices to I/O pins. For example, to connect the UART0 RX pin to AR0:
After programming the switchbox, the various sensors, actuators, and communication modules can be used.
I2C or IIC (Inter-Integrated Circuit) protocol
IIC is supported on libpynq. As described in the IIC library documentation in the libpynq documentation you can send and receive bytes with high-level IIC functions. The IIC must first be connected to the appropriate I/O pins.
GPIO and Parallel Communication
IO pins can be set to be input or output, and an output pin on one PYNQ board can be directly connected to an input pin on another PYNQ board. (The boards must always be grounded.) See the GPIO library documentation in the libpynq documentation.