It's easy to use the Arcade QT with CircuitPython using the Adafruit CircuitPython seesaw library. It allows you to write Python code to read the arcade button presses and control the LEDs.

You can use the Arcade QT with any CircuitPython microcontroller board or with a computer that has GPIO and Python thanks to Adafruit_Blinka, our CircuitPython-for-Python compatibility library.

CircuitPython Microcontroller Wiring

First wire up a Arcade QT breakout to your board exactly as follows. The following is the breakout wired to a QT Py RP2040 using the STEMMA connector:

  • Board 3V to breakout VIN (red wire)
  • Board GND to breakout GND (black wire)
  • Board SCL to breakout SCL (yellow wire)
  • Board SDA to breakout SDA (blue wire)

The following is the breakout wired to a QT Py RP2040 using a solderless breadboard:

  • Board 3V to breakout VIN (red wire)
  • Board GND to breakout GND (black wire)
  • Board SCL to breakout SCL (yellow wire)
  • Board SDA to breakout SDA (blue wire)

Python Computer Wiring

Since there's dozens of Linux computers/boards you can use we will show wiring for Raspberry Pi. For other platforms, please visit the guide for CircuitPython on Linux to see whether your platform is supported

Here's the Raspberry Pi wired with I2C using the STEMMA connector:

  • Pi 3V to breakout VIN (red wire)
  • Pi GND to breakout GND (black wire)
  • Pi SCL to breakout SCL (yellow wire)
  • Pi SDA to breakout SDA (blue wire)

Here's the Raspberry Pi wired with I2C using a solderless breadboard:

  • Pi 3V to breakout VIN (red wire)
  • Pi GND to breakout GND (black wire)
  • Pi SCL to breakout SCL (yellow wire)
  • Pi SDA to breakout SDA (blue wire)

Python Installation of seesaw Library

You'll need to install the Adafruit_Blinka library that provides the CircuitPython support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3. Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready!

Once that's done, from your command line run the following command:

  • pip3 install adafruit-circuitpython-seesaw

If your default Python is version 3 you may need to run pip instead. Just make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!

CircuitPython & Python Usage

To demonstrate using this breakout with CircuitPython, you'll install the necessary libraries, update your code, and then connect to the serial console to see the information printed out.

To use the Arcade QT breakout with CircuitPython, you need to first install the seesaw library, and its dependencies, into the lib folder on your CIRCUITPY drive.

Then you need to update code.py.

Click the Download Project Bundle button below to download the necessary libraries and the code.py file in a zip file. Extract the contents of the zip file, and copy the entire lib folder and the code.py file to your CIRCUITPY drive.

# SPDX-FileCopyrightText: 2022 Kattni Rembor for Adafruit Industries
# SPDX-License-Identifier: MIT
"""Arcade QT example that pulses the button LED on button press"""
import time
import board
import digitalio
from adafruit_seesaw.seesaw import Seesaw
from adafruit_seesaw.digitalio import DigitalIO
from adafruit_seesaw.pwmout import PWMOut

# The delay on the PWM cycles. Increase to slow down the LED pulsing, decrease to speed it up.
delay = 0.01

# For most boards.
i2c = board.I2C()

# For the QT Py RP2040, QT Py ESP32-S2, other boards that have SCL1/SDA1 as the STEMMA QT port.
# import busio
# i2c = busio.I2C(board.SCL1, board.SDA1)
arcade_qt = Seesaw(i2c, addr=0x3A)

# Button pins in order (1, 2, 3, 4)
button_pins = (18, 19, 20, 2)
buttons = []
for button_pin in button_pins:
    button = DigitalIO(arcade_qt, button_pin)
    button.direction = digitalio.Direction.INPUT
    button.pull = digitalio.Pull.UP
    buttons.append(button)

# LED pins in order (1, 2, 3, 4)
led_pins = (12, 13, 0, 1)
leds = []
for led_pin in led_pins:
    led = PWMOut(arcade_qt, led_pin)
    leds.append(led)

while True:
    for led_number, button in enumerate(buttons):
        if not button.value:
            for cycle in range(0, 65535, 8000):
                leds[led_number].duty_cycle = cycle
                time.sleep(delay)
            for cycle in range(65534, 0, -8000):
                leds[led_number].duty_cycle = cycle
                time.sleep(delay)
Use the commented out code for I2C setup if using a QT Py RP2040.

Now, press and hold the buttons to see the LED pulse.

That's all there is to using the Arcade QT with CircuitPython and the seesaw library!

Multi-Board Example

The following is an example of using two boards at the same time.

First, you need to update code.py.

Click the Download Project Bundle button below to download the necessary libraries and the code.py file in a zip file. Extract the contents of the zip file, and copy the entire lib folder and the code.py file to your CIRCUITPY drive.

To use multiple boards, you must alter the address jumpers on the back to change the I2C address on the additional boards. For this example, you must cut the trace on A0.
# SPDX-FileCopyrightText: 2022 Kattni Rembor for Adafruit Industries
# SPDX-License-Identifier: MIT
"""Arcade QT example for multiple boards that turns on button LED when button is pressed"""
import board
import digitalio
from adafruit_seesaw.seesaw import Seesaw
from adafruit_seesaw.digitalio import DigitalIO

# For most boards.
i2c = board.I2C()

# For the QT Py RP2040, QT Py ESP32-S2, other boards that have SCL1/SDA1 as the STEMMA QT port.
# import busio
# i2c = busio.I2C(board.SCL1, board.SDA1)
arcade_qt_one = Seesaw(i2c, addr=0x3A)
arcade_qt_two = Seesaw(i2c, addr=0x3B)

arcade_qts = (arcade_qt_one, arcade_qt_two)

# Button pins in order (1, 2, 3, 4)
button_pins = (18, 19, 20, 2)
buttons = []
for arcade_qt in arcade_qts:
    for button_pin in button_pins:
        button = DigitalIO(arcade_qt, button_pin)
        button.direction = digitalio.Direction.INPUT
        button.pull = digitalio.Pull.UP
        buttons.append(button)

# LED pins in order (1, 2, 3, 4)
led_pins = (12, 13, 0, 1)
leds = []
for arcade_qt in arcade_qts:
    for led_pin in led_pins:
        led = DigitalIO(arcade_qt, led_pin)
        led.direction = digitalio.Direction.OUTPUT
        leds.append(led)

while True:
    for led_number, button in enumerate(buttons):
        leds[led_number].value = not button.value
Use the commented out code for I2C setup if using a QT Py RP2040.

Press any button to turn on that button's LED.

That's all there is to using multiple Arcade QT boards with CircuitPython!

This guide was first published on Feb 02, 2022. It was last updated on 2022-02-04 11:51:33 -0500.

This page (Python & CircuitPython) was last updated on May 19, 2022.

Text editor powered by tinymce.