Getting Started with Adafruit Trinket
by Mike Barela
Copyright 2015 Mike Barela. All rights reserved.
Printed in the United States of America.
Published by Maker Media, Inc. , 1005 Gravenstein Highway North, Sebastopol, CA 95472.
Maker Media books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (.
- Editor: Brian Jepson and Emma Dvorak
- Production Editor: Matthew Hacker
- Copyeditor: Rachel Head
- Proofreader: Carla Thornton
- Interior Designer: David Futato
- Cover Designer: Brian Jepson
- Illustrator: Rebecca Demarest
- Cover Photographer: Andrew Tingle
- October 2014: First Edition
Revision History for the First Edition
- 2014-09-25: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781457185946 for release details.
Make:, Maker Shed, and Maker Faire are registered trademarks of Maker Media, Inc. The Maker Media logo is a trademark of Maker Media, Inc. Getting Started with Adafruit Trinket and related trade dress are trademarks of Maker Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and Maker Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
978-1-457-18594-6
[LSI]
Foreword
I like to talk about electronics and microcontrollers in terms of BA and AA (thats Before Arduino and After Arduino, by the way). In the days before Arduino, there were microcontrollers, to be sure. But it was really, really annoying to work with them. UV lamps, EEPROMs, one-time writes, high-voltage programmers! If you wanted to dabble in microcontrollers, the equipment and knowledge requirements were a steep hill to climb. Thanks to the beginner-friendly (but surprisingly powerful) Arduino, millions of engineers, artists, fashion designers, and more have been able to add electronics making to their skillsets.
At Adafruit, weve been doing Arduino projects for a very long time, and weve noticed that while some people like to push the capabilities to the very edge, there are many people who want something simple and small. A one-key keyboard, or an LED light-up brooch, or a servo driver. In many cases, the Arduino is great for prototyping but is a bit chunky. A smaller, simpler mini Arduino can do the job just fine. Thats why we designed the Trinket, a miniature microcontroller board that can do little tasks nicely, and can be programmed similarly to the Arduino.
The Trinket builds on the great work of the Arduino team, including David Mellis, who first added Atmel ATtiny85 chip support to the Arduino development environment. Even though it may seem underpowered, theres something about the tiny size and simplicity of the Trinket (and its wearable sister, the Gemma) that inspires so many projects.
Im delighted to introduce Mike Barela as the author of Getting Started with Adafruit Trinket. Mike has the deep engineering knowledge to explain the innards of a microcontroller or RC filter, the craftiness to detail how to build LED goggles, and the patience to line-by-line document the dozen projects in this book. As you read Getting Started with Adafruit Trinket, youll find yourself immersed in the joy of hacking and figuring things out, learning how to tweak just a little bit more out of the little Trinket, while gaining knowledge of the same kinds of topics youd run into with hulking 32-bit ARM processors.
Please try to build these projects, andbetter yetimprove on them! Show them off to your siblings, parents, children, or friends. Give them as gifts, wear them to parties, and show off how much fun it is to Make!
Limor Ladyada Fried, Founder and Engineer, Adafruit
Preface
The Trinket microcontroller provides designers with custom programmability in a size and price range perfect for modern projects. The number of projects using Trinket continues to grow, as witnessed in numerous project builds documented in social media. This book introduces you to some of the possibilities, providing a jumping-off point for your own explorations.
Who This Book Is For
This book is for you, the enthusiast who is expanding his knowledge of Making and controlling items through classes or self-study.
Working with Trinket is suitable for beginners, although it is assumed you have some familiarity with what a microcontroller is and with basic programming principles. The book steps through basic projects, working toward more challenging circuits and code. Youll find that I adapt and add concepts to create new functionality. After you complete the book, you can use it as a reference for microcontrollers, sensors, and coding techniques.
You will want to learn how to use the Arduino integrated development environment (IDE) for most of the examples in the book. Arduino compatibles are programmed in a variation of the C programming language with various prebuilt code in libraries. All of the code for the examples is supplied in the book and online. For later projects, familiarity with electronics and project assembly is helpful but not required.
You will be following diagrams illustrating point-to-point wiring of electrical circuits. Youll be working on a solderless breadboard, which makes this easy to complete.
Recommended Reading
There is no required reading to work with this book, but here are some suggested resources that you may draw on to better understand particular subjects:
Component soldering with a soldering iron
The book Make: Learn to Solder by Brian Jepson (Maker Media), Tyler Moskowite, and Gregory Hayes is a great reference. An alternative is the "Collins Lab: Soldering" tutorial, which you can watch for free online. Both teach the fundamentals of soldering, an essential skill for building electronic gadgets.
Familiarity with Arduino
The book Getting Started with Arduino, Second Edition, by Massimo Banzi (cocreator of Arduino), is a good resource, as is the Adafruit Learn Arduino series, available for free online. Both offer an introduction to the Arduino open source electronics prototyping platform, including programming.
Other resources are listed in .
What You Will Want to Have on Hand
To program a Trinket, you will need a Windows or Mac computer with a USB port. Linux may also work, although Adafruit does not guarantee compatibility with all Linux variants due to USB driver issues. Internet access is very helpful for obtaining example code, rather than typing it in yourself. The Internet is also great for reference material on specific subjects. The Adafruit Learning System and other websites post Trinket-related projects. Here are some other things youll need to have on hand:
A good USB type A male-to-male Mini-B cable
I cannot stress this enough: get a good USB cable for programming the Trinket. Please consider buying a substantial USB type A male end to type Mini-B male cable, 3 feet (1 meter) long or less. So many visitors to Adafruits Trinket support forum have repurposed old phone charging cables or other questionable cables. Such cables, more often than not, do not have the USB data wires required for communicating between the computer and the Trinket. Worn cables may work intermittently, but a good cable will save you hours of grief.