Linux Format

Control real-world hardware on your PC

Users of Raspberry Pi and Arduino SBCs are familiar with these boards’ GPIO (general purpose input/output) ports that enable them to interface to real-world electronic devices. PCs are devoid of GPIOs, but boards are available that provide that facility and connect to the PC via a USB port. Two such devices are the FT232H and the MCP2221, both from Adafruit, and here we see how to use them.

Our main emphasis is on hardware because we expect a lot of PC users who’ll be interested in this topic probably won’t have dabbled with SBCs and so won’t have learned much about electronics. Having said that, we provide some Python code to get you started and show you how to learn more.

These two boards differ in their number of various types of GPIO pins. The FT232H (£14.10 from Pimoroni) has 12 digital in/outs but no analogue in/outs, while the MCP2221 (£6.30 from Pimoroni) adds three analogue inputs, one of which can be used as an analogue output, but only has four digital in/outs, and three of these share pins with the analogue in/outs. Note that these boards have USB C sockets, so to connect them to your PC you’ll need either a USB C to USB A lead or, to use a common micro-USB to USB A lead, you’ll need an adapter, as you’ll see in our photos.

Installation and testing

We’ll be using Python to work with these boards. Although this will already be installed on your system, there are supporting elements you’ll need to install. Since installation instructions are provided for the FT232H at https: and for the MCP221 at https: we aren’t

You’re reading a preview, subscribe to read more.

More from Linux Format

Linux Format1 min read
Vector Vexations
Why does MySQL not support vectors in its community edition? Generative AI is the hot topic in tech. GenAI relies on vector data. Yet Oracle has no plans to support vectors in the community edition of MySQL. If you want to try out vector data with ot
Linux Format5 min read
Tips For Managing Docker Containers
Everyone knows how containers revolutionised application building and deployment. Using a E disposable stack of containers that make up an app that aren’t using the docker-compose command to manage the stack are missing a trick. It allows the shippin
Linux Format1 min read
Wine For Wayland
2023 was a great year for the Wayland driver for Wine. The goal was to move forward from the experimental phase and make the driver a proper upstream component. A year later, after several merge requests, many people are now already able to use the l

Related Books & Audiobooks