The seesaw firmware that ships with the ATtiny817 breakout includes analog capabilities on specific pins. This simple example reads the analog value of a pin.

Follow the instructions on the Python & CircuitPython page to get set up.

Analog Pins

The ATtiny817 breakout with seesaw firmware provides analog on the following pins:

  • 0, 1, 2, 3, 6, 7, 18, 19, 20

Example Code

Update your code.py to the following.

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

# Simple seesaw test reading analog value
# on SAMD09, analog in can be pins 2, 3, or 4
# on Attiny8x7, analog in can be pins 0, 1, 2, 3, 6, 7, 18, 19, 20

import time
import board
from adafruit_seesaw.seesaw import Seesaw
from adafruit_seesaw.analoginput import AnalogInput

ss = Seesaw(board.I2C())

analogin_pin = 2
analog_in = AnalogInput(ss, analogin_pin)

while True:
    print(analog_in.value)
    time.sleep(0.1)

Now, connect to the serial console to see the values printed out.

First you import the necessary modules and libraries. Then, you instantiate the seesaw on I2C.

Next, you choose the analog pin from which you would like to read values, in this case pin 2, and then set it up as an AnalogInput.

Inside the loop, you read the analog pin value and print it to the serial console. Finally, you include a short delay to keep the values readable.

That's all there is to using CircuitPython seesaw analog with the ATtiny817 breakout!

This guide was first published on Oct 20, 2021. It was last updated on 2021-10-20 12:04:17 -0400.

This page (Analog In) was last updated on Oct 20, 2021.

Text editor powered by tinymce.