Circuit Python Wiring & Test

Download Adafruit_CircuitPython_seesaw Library

To begin reading data from your Joy Featherwing, you will need to download Adafruit_CircuitPython_seesaw from our github repository. You can do that by visiting the github repo and manually downloading or, easier, just click this button to download the zip

Extract the zipped folder. And rename the folder it contains to Adafruit_seesaw.

Plug your CircuitPython device into your computer via the USB cable, and you should see the CIRCUITPY drive appear.

you should have the lib folder already on the drive. If you do not have the lib folder, or you encounter errors due to missing libraries, you can download the latest library package here.

 Drag the Adafruit_seesaw folder you just renamed to the CIRCUITPY/lib folder on your CircuitPython drive. The folder should look like this:

open the code.py file in the root of the CIRCUITPY drive and copy and paste the following code:

import time

from board import SCL, SDA
import busio
from micropython import const

from adafruit_seesaw.seesaw import Seesaw

# pylint: disable=bad-whitespace
BUTTON_RIGHT = const(6)
BUTTON_DOWN  = const(7)
BUTTON_LEFT  = const(9)
BUTTON_UP    = const(10)
BUTTON_SEL   = const(14)
# pylint: enable=bad-whitespace
button_mask = const((1 << BUTTON_RIGHT) |
                    (1 << BUTTON_DOWN) |
                    (1 << BUTTON_LEFT) |
                    (1 << BUTTON_UP) |
                    (1 << BUTTON_SEL))

i2c_bus = busio.I2C(SCL, SDA)

ss = Seesaw(i2c_bus)

ss.pin_mode_bulk(button_mask, ss.INPUT_PULLUP)

last_x = 0
last_y = 0

while True:
    x = ss.analog_read(2)
    y = ss.analog_read(3)

    if  (abs(x - last_x) > 3) or (abs(y - last_y) > 3):
        print(x, y)
        last_x = x
        last_y = y

    buttons = ss.digital_read_bulk(button_mask)
    if not buttons & (1 << BUTTON_RIGHT):
        print("Button A pressed")

    if not buttons & (1 << BUTTON_DOWN):
        print("Button B pressed")

    if not buttons & (1 << BUTTON_LEFT):
        print("Button Y pressed")

    if not buttons & (1 << BUTTON_UP):
        print("Button x pressed")

    if not buttons & (1 << BUTTON_SEL):
        print("Button SEL pressed")

    time.sleep(.01)

Plug your Joy Featherwing onto the top of your CircuitPython Feather board.

When you open the REPL you should see output when you press buttons or move the joystick.

Last updated on Apr 19, 2018 Published on Oct 25, 2017