Adafruit Attiny817 Seesaw
Adafruit Attiny817 Seesaw
https://learn.adafruit.com/adafruit-attiny817-seesaw
Overview 5
Analog In 19
• Analog Pins
• Example Code
Digital Input 21
• Digital Pins
• Wiring
• Example Code
NeoPixel 23
• NeoPixel Pins
• Wiring
• Example Code
PWMOut 26
• PWM Pins
• Wiring
• Example Code
Python Docs 30
Arduino 30
• Wiring
• Library Installation
• Load Example
Analog In 33
• Analog Pins
• Example Code
PWM 35
• PWM Pins
• Wiring
• Example Code
NeoPixel 37
• NeoPixel Pins
• Wiring
• Example Code
EEPROM 41
• Example Code
GPIO 47
• Function Registers
• GPIO register setup on SAMD09:
• GPIO register setup on ATTiny8x7:
• DIRSET (0x02, 32 bits, Write Only)
• DIRCLR (0x03, 32 bits, Write Only)
• GPIO (0x04, 32 bits, Read/Write)
• SET (0x05, 32 bits, Write Only)
• CLR (0x06, 32 bits, Write Only)
• TOGGLE (0x07, 32 bits, Write Only)
• INTENSET (0x08, 32 bits, Write Only)
• INTENCLR (0x09, 32 bits, Write Only)
• INTFLAG (0x0A, 32 bits, Read Only)
• PULLENSET (0x0B, 32 bits, Write Only)
• PULLENCLR (0x0C, 32 bits, Write Only)
Interrupts 56
EEPROM 56
• Function Registers
• SAMD09
• ATtiny817
• Function Registers 57
• PIN (0x01, 8bits, Write Only)
• SPEED (0x02, 8bits, Write Only)
• BUF_LENGTH (0x03, 16bits LE, Write Only)
• BUF (0x04, 32 bytes, Write Only)
• SHOW (0x05, no args, Write Only)
PWM 59
• Nomenclature
• Function Register Summary
• Function Register Description
• 0x01 - PWM_VAL
• 0x02 - PWM_FREQ
• Port Specific Details
• SAMD
• ATtiny
megaTinyCore Docs 69
Downloads 69
• Files
• ATtinyx16 Breakout Schematic and Fab Print
• ATtiny817 Breakout Schematic and Fab Print
These are the Adafruit ATtiny817, ATtiny816 and ATtiny1616 breakouts with seesaw!
These breakout boards are a "three in one" product:
1. The ATtiny817, ATtiny816 and ATtiny1616 are part of the 'next gen' of AVR
microcontrollers, and now we have a cute development/breakout board for
them, with just enough hardware to get the chip up and running.
2. It's also an Adafruit seesaw board. Adafruit seesaw is a near-universal converter
framework which allows you to add and extend hardware support to any I2C-
capable microcontroller or microcomputer. Instead of getting separate I2C GPIO
expanders, ADCs, PWM drivers, etc, seesaw can be configured to give a wide
range of capabilities.
3. Finally, with STEMMA QT connectors on it, you could use it as either an I2C
controller or peripheral with plug-and play support.
Each breakout comes with the assembled and tested board, as well as some header
strips. Each PCB is fairly minimal and contains:
For example, using the ATtiny817 breakout with the pre-burned seesaw firmware
gives you:
Using the ATtinyx16 breakouts with pre-burned seesaw firmware gives you:
Of course you can configure or reprogram the chip to however you want to use it - we
like using SpenceKonde's megaTinyCore which brings Arduino peripheral
support (https://adafru.it/VdM) to this series of chips. To program the chip you will
Please note: The boards do not come with a bootloader. If you want to do
development on seesaw (e.g. changing the configuration) you need a separate UPDI
programming setup! The firmware we put on is available as this example
sketch (https://adafru.it/VdN), compiled using the megaTinyCore. We don't provide any
support for custom builds of seesaw - we think this is cool and useful for the Maker
community!
Power Pins:
• Vin - this is the power pin. The ATtinyx16 operates between 1.8V and 5.5V.
However, we still included a 3.3V voltage regulator. You can power the board
from 2V to 5V. It defaults to Vin voltage, which can be between 3.3V and 5V, or
cut the jumper on the back and bridge the other pad to select 3.3V logic.
If you swap the jumper on the back to select 3.3V logic, the ATtiny should be
kept at the (pre-programmed default) 10MHz and not set faster
I2C
• SCL - This is the I2C clock pin. Connect to your microcontrollers I2C clock line.
There is a 10K pullup on this pin to Vin.
• SDA - This is the I2C data pin. Connect to your microcontrollers I2C data line.
There is a 10K pullup on this pin to Vin.
• STEMMA QT (https://adafru.it/Ft4) - These I2C connectors, located on each end
of the board, have 10K pullup resistors. They allow you to connect to
development boards with STEMMA QT connectors, or to other things, with
various associated accessories (https://adafru.it/Ft6).
• 12 / AD0 - This is the ADDR0 pin. Connect this to ground to increment the
device's I2C address by 1.
• 13 / AD1 - this is the ADDR1 pin. Connect this to ground to increment the
device's I2C address by 2.
ADC Pins:
• 0-5, 14, 15, 16 - There are nine 10-bit ADC pins.
PWM Pins:
• 0, 1, 7, 11, 16 - There are five 8-bit PWM output pins.
Programming Pins:
• UPDI - This is the single-pin Unified Program and Debug Interface. This pin is for
external programming or on-chip-debugging. It uses the reset pin on the ATtiny.
There is no reset on this breakout! It is used for the UPDI programming pin, and
cannot be used to reset the board!
Power Pins:
• Vin - this is the power pin. The ATtiny8x7 operates between 1.8V and 5.5V.
However, we still included a 3.3V voltage regulator. You can power from 3.3V to
5V. It defaults to Vin voltage, which can be between 3.3V and 5V, or cut the
jumper on the back and bridge the other pad to select 3.3V logic.
• 3Vo - This is the 3.3V output from the voltage regulator. You can grab up to
100mA from this if you like.
• GND - This is common ground for power and logic.
If you swap the jumper on the back to select 3.3V logic, the ATtiny should be
kept at the (pre-programmed default) 10MHz and not set faster
• SCL - This is the I2C clock pin. Connect to your microcontrollers I2C clock line.
There is a 10K pullup on this pin to Vin.
• SDA - This is the I2C data pin. Connect to your microcontrollers I2C data line.
There is a 10K pullup on this pin to Vin.
• STEMMA QT (https://adafru.it/Ft4) - These I2C connectors, located on each end
of the board, have 10K pullup resistors. They allow you to connect to
development boards with STEMMA QT connectors, or to other things, with
various associated accessories (https://adafru.it/Ft6).
Pins 15, 16 and 17 can NOT be used as GPIO pins with the seesaw firmware!
• 16 / AD0 - This is the ADDR0 pin. Connect this to ground to increment the
device's I2C address by 1.
• 17 / AD1 - this is the ADDR1 pin. Connect this to ground to increment the device's
I2C address by 2.
ADC Pins:
• 0, 1, 2, 3, 6, 7, 18, 19, 20 - There are nine 10-bit ADC pins.
PWM Pins:
• 0, 1, 9, 12, 13 - There are five 8-bit PWM output pins.
Programming Pins:
• UPDI - This is the single-pin Unified Program and Debug Interface. This pin is for
external programming or on-chip-debugging. It uses the reset pin on the ATtiny.
There is no reset on this breakout! It is used for the UPDI programming pin, and
cannot be used to reset the board!
You can use this sensor with any CircuitPython microcontroller board or with a
computer that has GPIO and Python thanks to Adafruit_Blinka, our CircuitPython-for-
Python compatibility library (https://adafru.it/BSN).
Once that's done, from your command line run the following command:
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 Usage
To use with CircuitPython, you need to first install the seesaw library into the lib folder
on your CIRCUITPY drive. Then you need to update code.py with the example script.
Thankfully, you can do this in one go. In the example below, 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.
• adafruit_bus_device/
Python Usage
Once you have the library pip3 installed on your computer, copy or download the
following example to your computer, and run the following, replacing code.py with
whatever you named the file: python3 code.py
Example Code:
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
# SPDX-License-Identifier: MIT
"""
Simple seesaw test for ATtiny8x7 breakout using built-in LED on pin 5.
"""
import time
import board
from adafruit_seesaw.seesaw import Seesaw
ss.pin_mode(5, ss.OUTPUT)
while True:
ss.digital_write(5, False) # Turn the LED on (the built-in LED is active low!)
time.sleep(1) # Wait for one second
ss.digital_write(5, True) # Turn the LED off
time.sleep(1) # Wait for one second
If running CircuitPython: Once everything is saved to the CIRCUITPY drive, the built-
in LED will begin blinking!
If running Python: Once you run the example, the built-in LED will begin blinking!
Inside the loop, you first set the LED to False to turn it on. False is the voltage
level. You set it to False to turn it on because the LED is tied active low. Then, you
wait for one second. Next, you turn off the LED by setting it to True , and then wait
one more second before beginning the loop again.
That's all there is to blinking the built-in LED on the ATtiny817 breakout using
CircuitPython and the seesaw library!
Analog In
The seesaw firmware that ships with the ATtinyxxx breakouts includes analog
capabilities on specific pins. This simple example reads the analog value of a pin.
Though the Fritzing diagrams depict an ATtiny817, the examples work as written
with the ATtiny816 and ATtiny1616.
• 0-3, 6, 7, 18-20
The ATtiny816 and ATtiny1616 breakout with seesaw firmware provides analog on the
following pins:
• 0-5, 14-16
Example Code
Update your code.py to the following.
import time
import board
from adafruit_seesaw.seesaw import Seesaw
from adafruit_seesaw.analoginput import AnalogInput
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.
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 ATtinyxxx breakouts!
Digital Input
The seesaw firmware that ships with the ATtinyxxx breakouts includes digital
capabilities on specific pins. This example blinks the turns on the built-in LED when a
button is pressed.
Though the Fritzing diagrams depict an ATtiny817, the examples work as written
with the ATtiny816 and ATtiny1616.
Digital Pins
There are 15 pins on the ATtiny817 breakout that can be used with digitalio:
There are 12 pins on the ATtinyx16 breakouts that can be used with digitalio:
Wiring
Connect a button up to your already wired up breakout as follows.
Example Code
Update your code.py to the following.
# Simple seesaw test using an LED attached to Pin 5 and a button on pin 2
#
# See the seesaw Learn Guide for wiring details.
# For SAMD09:
# https://learn.adafruit.com/adafruit-seesaw-atsamd09-breakout?
view=all#circuitpython-wiring-and-test
# For ATtiny8x7:
# https://learn.adafruit.com/adafruit-attiny817-seesaw/digital-input
import time
import board
import digitalio
from adafruit_seesaw.seesaw import Seesaw
from adafruit_seesaw.digitalio import DigitalIO
button_pin = 2
led_pin = 5
while True:
# simply set the LED to the same 'value' as the button pin
led.value = button.value
time.sleep(0.1)
Now, press the button to see the little red LED light up! Release the button to turn it
off.
Next, you choose the button pin and LED pin. The button is on pin 2, and the built-in
LED is on pin 5.
Then you create the button object, and set it up as an input with a pullup. Following
that, you create the LED object and set up the pin as an output.
Finally, inside the loop, you simply set the LED state equal to the button state with a
0.1 second delay for debounce.
That's all there is to using CircuitPython seesaw digitalio with the ATtinyxxx breakouts!
NeoPixel
The seesaw firmware that ships with the ATtinyxxx breakouts include the ability to
power up to 60 NeoPixels on one pin. This example displays a rainbow across a
NeoPixel ring.
There are 15 pins on the ATtiny817 breakout that can be used for powering NeoPixels:
There are 12 pins on the ATtinyx16 breakouts that can be used for powering
NeoPixels:
Wiring
As stated above, you can use many different pins for powering NeoPixels, but this
example uses pin 19. Connect a NeoPixel ring (or strip) to the breakout as follows.
If you are using an ATtinyx16, there is no pin 19. Connect the NeoPixel IN pin to
one of the 12 NeoPixel capable pins listed above.
Example Code
Update your code.py to the following. If you are using an ATtinyx16, update
NEOPIXEL_PIN to be one of the NeoPixel capable pins listed above to match your
wiring.
import time
import board
from rainbowio import colorwheel
from adafruit_seesaw import seesaw, neopixel
Next, you set the NeoPixel pin, and the number of pixels to match your wiring and
pixel number. This example uses pin 19 and a 12-pixel ring.
Then, you create the pixels object with the pin and number you set above.
Before the loop, you set pixel brightness to 30% and create a color_offset
variable and set it to 0 to start the colorwheel at red.
Inside the loop, you display the rainbow with a slight delay. Increase this to slow down
the rainbow if desired.
That's all there is to using CircuitPython seesaw NeoPixel with the ATtinyxxx
breakouts!
PWMOut
The seesaw firmware that ships with the ATtinyxxx breakouts includes PWM
capabilities on specific pins. This example fades an external LED.
PWM Pins
The ATtiny817 breakout with seesaw firmware provides PWM on the following pins:
• 0, 1, 9, 12, 13
The ATtiny816 and ATtiny1616 breakouts with seesaw firmware provides PWM on the
following pins:
• 0, 1, 7, 11, 16
Wiring
This example uses an external LED. Wire it up as follows.
If you are using an ATtinyx16, pin 12 is not a PWM pin. Connect the anode (+) pin
of the LED to one of the 5 PWM capable pins listed above.
Example Code
Update your code.py to the following. If you are using an ATtinyx16, update PWM_PIN
to be one of the PWM capable pins listed above to match your wiring.
import time
import board
from adafruit_seesaw import seesaw, pwmout
delay = 0.01
while True:
# The API PWM range is 0 to 65535, but we increment by 256 since our
# resolution is often only 8 bits underneath
for cycle in range(0, 65535, 256): #
led.duty_cycle = cycle
time.sleep(delay)
for cycle in range(65534, 0, -256):
The brightness of the LED will fade up and then down, and repeat!
First, you import all the necessary modules and libraries. Then you instantiate the
seesaw on I2C.
Next, you choose a pin for the LED, and then create the LED PWMOut object and
provide it the PWM_PIN .
Inside the loop, you initially cycle up through the PWM range (0 - 65535) in
increments 0f 256, and once complete, cycle down from the max back to 0 in
increments of 256. The step is limited to increments of 256 because the resolution is
often only 8 bits underneath. Both cycles have the delay included.
That's all there is to using CircuitPython seesaw PWM to fade an LED on the ATtinyxxx
breakouts!
EEPROM
The seesaw firmware that ships with the ATtinyxxx breakouts provides access to the
128 byte EEPROM. This example reads from and writes to the EEPROM.
Example Code
Update your code.py to the following.
Before saving the file, connect to the serial console. The print statements are only
sent the first time the code runs, so if you connect after you save the file, you may not
see them printed to the serial console.
import time
import board
from adafruit_seesaw import seesaw
print("Incrementing value")
ss.eeprom_write8(0x02, (value + 1) % 0xFF)
while True:
# Do not write EEPROM in a loop, it has 100k cycle life
time.sleep(1)
The print statements will show up in the serial console, but only the first time the
code is run. If you connect to the serial console after saving, you may not see
anything as there are no prints in the loop.
First, you import all the necessary modules and libraries, and you instantiate the
seesaw on I2C.
Inside the loop, is a 1 second delay. Do not write EEPROM in a loop, because it has a
100k cycle life.
Python Docs
Python Docs (https://adafru.it/C5y)
Arduino
The Adafruit Seesaw library makes it easy to use your ATtinyxxx breakout with
Arduino. Install the necessary libraries, and load the examples to use your ATtinyxxx
breakout for all sorts of purposes. This example is designed to verify that your
breakout is working - it simply blinks the built-in LED. No hardware other than the
breakout and microcontroller is needed.
Though the Fritzing diagrams depict an ATtiny817, the examples work as written
with the ATtiny816 and ATtiny1616.
Wiring
You can use many different Arduino boards, but this example shows the QT Py M0,
and the Adafruit Metro. Connect up the ATtiny817 breakout as shown below.
Library Installation
You can install the Adafruit Seesaw Library for Arduino using the Library Manager in
the Arduino IDE:
Click the Manage Libraries ... menu item, search for seesaw, and select the Adafruit
Seesaw library:
Load Example
Open up File -> Examples -> Adafruit Seesaw -> digital -> attiny_blink and upload to
your Arduino wired up to the breakout.
Upload the sketch to your board and open up the Serial Monitor (Tools->Serial
Monitor). You should see seesaw started ok! . If you don't, check your wiring.
If using the STEMMA QT version of the board, you'll need to use Wire1 like this:
Adafruit_seesaw ss(&Wire1) ;
/*
* This example shows how to blink a pin on a seesaw.
* It is written to use the built-in LED on the ATtiny817 breakout with seesaw.
*/
#include "Adafruit_seesaw.h"
Adafruit_seesaw ss;
#define BLINK_PIN 5
void setup() {
Serial.begin(115200);
if(!ss.begin()){
Serial.println("seesaw not found!");
while(1) delay(10);
}
void loop() {
ss.digitalWrite(BLINK_PIN, LOW); // turn the LED on (the LED is tied low)
delay(1000); // wait for a second
ss.digitalWrite(BLINK_PIN, HIGH); // turn the LED off
delay(1000);
}
Once you've successfully loaded the sketch onto your board, the little red LED will
begin blinking!
Analog In
The seesaw firmware that ships with the ATtinyxxx breakouts includes analog
capabilities on specific pins. This example reads the analog value of a pin.
Follow the steps on the Arduino page (https://adafru.it/VrF) to get set up.
Analog Pins
The ATtiny817 breakout with seesaw firmware provides analog on the following pins:
• 0-3, 6, 7, 18-20
• 0-5, 14-16
Example Code
Open up File -> Examples -> Adafruit Seesaw -> analog -> analogRead and upload to
your Arduino wired up to the breakout.
/*
* This example shows how read the ADC on a seesaw.
* The default ADC pins on the SAMD09 Breakout are 2, 3, and 4.
*/
#include "Adafruit_seesaw.h"
Adafruit_seesaw ss;
// on SAMD09, analog in can be 2, 3, or 4
// on Attinyxy7, analog in can be 0-3, 6, 7, 18-20
// on Attinyxy6, analog in can be 0-5, 14-16
#define ANALOGIN 2
void setup() {
Serial.begin(115200);
if(!ss.begin()){
Serial.println(F("seesaw not found!"));
while(1) delay(10);
}
void loop() {
Serial.println(ss.analogRead(ANALOGIN));
delay(50);
}
Once you've successfully loaded the sketch onto your board, open the Serial Monitor
(Tools->Serial Monitor). Your output should look something like the following.
Follow the steps on the Arduino page (https://adafru.it/VrF) to get set up.
PWM Pins
The ATtiny817 breakout with seesaw firmware provides PWM on the following pins:
• 0, 1, 9, 12, 13
The ATtiny816 and ATtiny1616 breakouts with seesaw firmware provides PWM on the
following pins:
• 0, 1, 7, 11, 16
Wiring
Follow the instructions to add an external LED to your existing setup.
If you are using an ATtinyx16, pin 12 is not a PWM pin. Connect the anode (+) pin
of the LED to one of the 5 PWM capable pins listed above.
Before you upload it to your microcontroller, you must make a change for it to work
with the ATtinyxxx breakouts.
This example will not work with the ATtinyxxx breakouts as is. You must update
the led pin before uploading the sketch!
You must do this before uploading the sketch, or it won't work with your setup!
/*
Fade
This example shows how to fade an LED on pin 6 of a seesaw board using the
analogWrite()
function.
The analogWrite() function uses PWM, so if you want to change the pin you're
using, be sure to use another PWM capable pin.
On the SAMD09 breakout these are pins 5, 6, and 7
On the ATtinyxy7 breakout these are pins 0, 1, 9, 12, 13
On the ATtinyxy6 breakout these are pins 0, 1, 7, 11, 16
*/
#include "Adafruit_seesaw.h"
Adafruit_seesaw ss;
if(!ss.begin()){
Serial.println("seesaw not found!");
while(1) delay(10);
}
}
Once you've successfully uploaded the sketch to your board, open the Serial Monitor
(Tools->Serial Monitor), and the LED will begin to fade bright and dim!
NeoPixel
The seesaw firmware that ships with the ATtinyxxx breakouts includes the ability to
power up to 60 NeoPixels on one pin. This example displays a series of color wipes, a
theatre chase effect in different colors, and a rainbow across a NeoPixel ring.
Follow the steps on the Arduino page (https://adafru.it/VrF) to get set up.
NeoPixel Pins
Only one pin can be used at a time for powering NeoPixels on the ATtinyxxx
breakouts!
There are 12 pins on the ATtinyx16 breakouts that can be used for powering
NeoPixels:
Wiring
Follow the instructions to add an external LED to your existing setup.
If you are using an ATtinyx16, there is no pin 19. Connect the NeoPixel IN pin to
one of the 12 NeoPixel capable pins listed above.
Example Code
Open up File -> Examples -> Adafruit Seesaw -> NeoPixel -> NeoPixel_strandtest.
Before you upload it to your microcontroller, you must make a change for it to work
with the ATtinyxxx breakout.
This example will not work with the ATtinyxxx breakout as is. You must update
the pin before uploading the sketch!
#define PIN 8
You must do this before uploading the sketch, or it won't work with your setup!
#include <seesaw_neopixel.h>
#define PIN 10
void setup() {
Serial.begin(115200);
if(!strip.begin()){
Serial.println("seesaw not found!");
while(1) delay(10);
}
void loop() {
// Some example procedures showing how to display to the pixels:
colorWipe(strip.Color(255, 0, 0), 50); // Red
colorWipe(strip.Color(0, 255, 0), 50); // Green
colorWipe(strip.Color(0, 0, 255), 50); // Blue
//colorWipe(strip.Color(0, 0, 0, 255), 50); // White RGBW
// Send a theater pixel chase in...
theaterChase(strip.Color(127, 127, 127), 50); // White
theaterChase(strip.Color(127, 0, 0), 50); // Red
theaterChase(strip.Color(0, 0, 127), 50); // Blue
rainbow(20);
rainbowCycle(20);
theaterChaseRainbow(50);
}
delay(wait);
delay(wait);
Once successfully uploaded, your NeoPixel light show will begin! Color wipe, followed
by theatre chase, followed by full rainbow, followed by rainbow cycle.
EEPROM
The seesaw firmware that ships with the ATtinyxxx breakouts provides access to the
128 byte EEPROM. This example reads from and writes to the EEPROM.
Follow the steps on the Arduino page (https://adafru.it/VrF) to get set up.
Example Code
Open up File -> Examples -> Adafruit Seesaw -> EEPROM.
/*
* This example shows how to read and write EEPROM data. Try writing
* then removing power from both devices, commenting out the write, and
* uploading again.
*/
#include "Adafruit_seesaw.h"
void setup() {
uint8_t eepromval;
Serial.begin(115200);
if(!ss.begin()){
Serial.println(F("seesaw not found!"));
while(1) delay(10);
}
void loop() {
//DONT WRITE EEPROM IN A LOOP!!!! YOU WILL DESTROY YOUR FLASH!!!
}
Once you've successfully uploaded the sketch to your board, open the Serial Monitor
(Tools->Serial Monitor), and see the info printed out!
The sections under this heading contain more detailed information about how the
Seesaw platform works. If you are using our Arduino, CircuitPython, or Python API
you can skip these sections. These sections are intended for people who either want
to understand and modify seesaw, or who want to make their own API for a platform
that is not officially supported by Adafruit such as C/C++ on Raspberry Pi.
If you are an end user of a seesaw device, then it is the support libraries you want.
Firmware
Support Libraries
The I2C bus on the SAMD09 is 3.3V logic level, but all boards other than the SAMD09
breakout have level shifting so you can use 3 or 5V logic. Boards with Attiny chips are
3 or 5V safe so you can use either for power and logic
I2C pullup resistors are included in our SeeSaw boards but if you are DIY'ing, be sure
to add your own! 2.2K - 10K is a good range.
This address can be modified using the address select pins, there can be multiple
address pins. If address select pin 0 (A0) is tied to ground on boot, the I2C address is
incremented by 1. If address select pin 1 (A1) is pulled low, the I2C address is
incremented by 2. If both address select pins are pulled low, the I2C address is
incremented by 3. Thus you can, with the same hardware, have up to 4 devices
On both the SAMD09 and Attiny817 breakouts, the default A0 pin is 16, default A1 pin
is 17. On boards where the chips are embedded, there may be as many as 4 address
pins, they'll be labeled with jumpers
The base I2C address can also be modified by writing a new address to EEPROM. See
the EEPROM section for more information.
I2C Transactions
We recommend using 100KHz I2C, but speeds of up to 400KHz are supported. You
may want to decrease the SDA/SCL pullups to 2.2K from 10K in that case.
Writing Data
A seesaw write command consists of the standard I2C write header (with the R/W bit
set to 0), followed by 2 register bytes followed by zero or more data bytes.
The first register byte is the module base register address. Each module (GPIO, ADC,
DAC, etc.) has it's own unique 8 bit base identifier.
The second register byte is the module function register address. This byte specifies
the desired register within the module to be written.
Thus we have up to 254 modules available (0x00 is reserved) and 255 functions per
module - plenty to allow all sorts of different capabilities!
The Arduino UNO Wire library implementation has a limit of 32 bytes per
transaction so be aware you may not be able to read/write more than that
amount. We have designed the library to work within those constraints
0x00 Status
GPIO
0x01
0x08 PWM
0x09 ADC
Interrupt
0x0B
0x0C DAP
0x0D EEPROM
0x0E NeoPixel
0x0F Touch
Keypad
0x10
0x11 Encoder
Reading Data
A register read is accomplished by first sending the standard I2C write header,
followed by the two register bytes corresponding to the data to be read. Allow a short
delay, and then send a standard I2C read header (with the R/W bit set to 1) to read the
data.
The length of the required delay depends on the data that is to be read. These delays
are discussed in the sections specific to each module.
In code, this may look like this (using the Arduino wire I2C object):
delayMicroseconds(delay);
Wire.requestFrom((uint8_t)_i2caddr, num);
GPIO
The GPIO module provides every day input and outputs. You'll get logic GPIO pins
that can act as outputs or inputs. With pullups or pulldowns. When inputs, you can
also create pin-change interrupts that are routed the the IRQ pin.
The module base register address for the GPIO module is 0x01.
Function Registers
Writes of GPIO function registers should contain 4 data bytes (32 bits) following the
initial register data bytes. Each bit in these registers represents a GPIO pin on PORTA
of the seesaw device.
If the corresponding pin does not exist on the SeeSaw device, then reading or writing
the bit has no effect.
We decided to go with this method to make GPIO toggling fast (rather than having
one i2c transaction per individual pin control) but the host processor will need to do a
little work to keep the pins identified.
• Bit 0: PA4
• Bit 1: PA5
• Bit 2: PA6
• Bit 3: PA7
• Bit 4: PB7
• Bit 5: PB6
• Bit 6: PB5
• Bit 7: PB4
• Bit 8: PB3
• Bit 9: PB2
• Bit 10: PB1
• Bit 11: PB0
• Bit 12: PC0
• Bit 13: PC1
• Bit 14: PC2
• Bit 15: PC3
• Bit 16: PC4
• Bit 17: PC5
• Bit 18: PA1
• Bit 19: PA2
• Bit 20: PA3
All bits that are set to 1 will have their corresponding pins set HIGH.
Reading this register reads all pins on of the seesaw device. On the Attiny series
please wait at least 250uS between command write and data read to allow the data
to be read and formatted for retrieval. Reading this register will also reset the IRQ pin
if it was configured.
When reading ADC data, there should be at least a 500 uS delay between writing the
register number you would like to read from and attempting to read the data.
Allow a delay of at least 1ms in between sequential ADC reads on different channels.
Channel 0 PA02
Channel 1 PA03
Channel 2 PA04
Channel 3 PA05
(These are the same as the Arduino GPIO pin names for the ADCs in
megaTinyCore (https://adafru.it/YEh))
0x1B
CHANNEL_20 16-bit Read Only
Bits 31 - 16 Bits 15 - 0
...
Once the interrupt is triggered, it can be only be cleared when the conditions of it's
source module(s) have been met (e.g. data has been read, an interrupt has been
cleared by reading an INTFLAG register).
See individual module sections for details on their available interrupt configurations.
EEPROM
The EEPROM module provides persistent storage of data across reboots.
On the SAMD09, there are 64 bytes of emulated EEPROM available for use. Byte 63
(0x3F) can be written to change the devices default I2C address.
On the ATtiny817, there are 128 bytes of actual EEPROM available for use. Byte 127
(0x7F) can be written to change the device's default I2C address.
The module base register address for the EEPROM module is 0x0D
The SAMD09 does not have true EEPROM, but flash memory on the seesaw that
performs the same function. Performing a chip erase will erase all data stored in
the emulated EEPROM. Also, be aware that the emulated EEPROM has a limited
write/erase cycle lifespan. Care should be taken to not write/erase too many
times or you will get inconsistant results and possibly damage the FLASH! The
FLASH is rated for 100,000 cycles
Function Registers
SAMD09
ATtiny817
The seesaw has built in NeoPixel support for up to 170 RGB or 127 RGBW pixels. The
output pin as well as the communication protocol frequency are configurable. Note:
older firmware is limited to 63 pixels max.
The module base register address for the NeoPixel module is 0x0E.
Function Registers
0x00 = 400khz
Bytes 0 - 1 Bytes 2 - 32
PWM
0x08 Base Register Address
This module provides support for Pulse Width Modulation (PWM) output.
Nomenclature
The seesaw PWM Function Registers are defined using a generic nomenclature as
follows:
See the Port Specific Details section below for further information.
Sets the PWM Value for a specified PWM Number. The first byte written is the PWM
Number. The next two bytes are the 16 bit PWM Value, most significant byte (MSB)
followed by least significant byte (LSB).
0x02 - PWM_FREQ
Sets the PWM Frequency for a specified PWM Number. The first byte written is the
PWM Number. The next two bytes are the 16 bit PWM Frequency, most significant
byte (MSB) followed by least significant byte (LSB).
1 PA05
2 PA06
3 PA07
The full 16 bit PWM Value is used. This value should be an unsigned integer ranging
from 0 for full off to 65535 for full on.
The PWM Frequency is a 16 bit unsigned integer value which specifies the frequency
in hertz (Hz).
ATtiny
The PWM Number is the Arduino GPIO pin number.
Currently, only the MSB of the 16 bit PWM Value is used. This is due to the 8 bit limit
of analogWrite() used internally. However, a full 16 bit value should be sent from 0 for
full off to 65535 for full on.
The PWM Frequency is a 16 bit unsigned integer value which specifies the frequency
in hertz (Hz). (NOTE: uses tone() internally)
You can reprogram these ATtiny breakouts to run your own firmware. However, the
boards do not come with a bootloader. If you want to do development on seesaw (e.g.
changing the configuration) you need a separate UPDI programming setup! You can
build this setup with a 1K resistor and a USB to Serial cable or with the UPDI Friend
board.
Install megaTinyCore
You can compile code for the ATtiny using the megaTinyCore (https://adafru.it/VdM)
board support package in the Arduino IDE. There are detailed installation
instructions (https://adafru.it/19e4) in the megaTinyCore GitHub repository. The
following steps outline how to install it using the Boards Manager.
In the Arduino IDE, go to Preferences and add the megaTinyCore boards manager
URL to the Additional Boards Manager URLs list:
http://drazzy.com/package_drazzy.com_index.json
In the Boards Manager, search for megaTinyCore. Click Install to install the board
support package.
Next, set clock if needed. The default 20 MHz clock option is only valid if powering
with 5V. If powering with 3.3V, select 10 MHz for the clock.
Finally, go to Preferences and check off Show verbose output during upload. This
will give you the upload details and progress in the monitor at the bottom of the
Arduino IDE, which is very useful for debugging.
Blink Test
This simple example blinks the ATTiny816 onboard red indicator LED on pin 10.
void setup() {
pinMode(10, OUTPUT);
}
void loop() {
digitalWrite(10, HIGH);
delay(1000);
digitalWrite(10, LOW);
delay(1000);
}
If using this with the ATTiny817, you'll want to update the pin to 5, as shown below.
void setup() {
pinMode(5, OUTPUT);
}
void loop() {
digitalWrite(5, HIGH);
delay(1000);
digitalWrite(5, LOW);
delay(1000);
}
Upload the sketch using the UPDI programmer. You should see this output in the
monitor after the upload has completed successfully:
After selecting the corresponding firmware sketch, upload it to your board using the
UPDI programmer. You can confirm that the seesaw firmware was successfully
uploaded by connecting the ATtiny breakout to a board via I2C and performing an I2C
scan. The address 0x49 should appear.
megaTinyCore Docs
megaTinyCore Docs (https://adafru.it/VdM)
Downloads
Files
• ATtiny8x7 datasheet (https://adafru.it/VhF)
• ATtiny816 Datasheet (https://adafru.it/18EI)
• ATtiny1616 Datasheet (https://adafru.it/18HB)
• ATtiny817 EagleCAD PCB files on GitHub (https://adafru.it/Via)
• ATtinyx16 EagleCAD PCB files on GitHub (https://adafru.it/19e5)
• ATtiny817 Fritzing object in the Adafruit Fritzing Library (https://adafru.it/Vib)
• ATtinyx16 Fritzing object in the Adafruit Fritzing Library (https://adafru.it/19e6)