Note: This excerpt is adapted from author Mike Barela’s new Make: Book, Getting Started with Adafruit Trinket.

The Arduino has revolutionized the use of microcontrollers—programmable electronics—in the last several years. This can be attributed to easy to use hardware and software at a reasonable price point. The often-cited Internet of Things has grown from the ubiquity of easy to use programmable electronics, sensors, and communications.

One of the few arguments that typically comes about after building a permanent project is “I put my Arduino Uno in the project, now I am ‘out’ my $30 Uno.” That, and many projects do not require all the horsepower and connectivity an Arduino Uno or larger board offers.

trinket v unofeature compUsing Trinket

Many projects do not require the size, power, and capabilities of larger Arduino compatibles. Here are some categories of projects where Trinket may be a good choice:

Wearables

A very fast growing use for electronics. With its small size and low power requirements, Trinket is being used in a growing number of clothing and body wear projects.

Sensing

The Internet of Things is composed of many small smart sensors communicating information on the world around us. Trinket is perfect for attaching a wide variety of sensors and displaying or communicating sensor status.

Tiny Projects 

This is any use where programmability is desired in a small package. Very small robotics projects can be made with Trinket.

Lights and Display

Coupled with light emitting diodes (LEDs), Trinket is a great choice for DIY lighting projects. Used with smart red-green-blue (RGB) LEDs, Trinket can perform complex light animations. Adafruit’s smart RGB LEDs, Neopixels, are controlled with only one data pin. You can drive LED and character displays with only two pins.

New uses for Trinket appear regularly on Internet project sites including Instructables, Google+, and the Adafruit blog and forums

The ATtiny85 Microcontroller

At the heart of Trinket is the ATtiny85 microcontroller, produced by Atmel Corporation. Despite having only 8 pins in a tiny package, this controller provides the functionality of traditionally larger processors.

tiny

Memory

The Attiny85 has 8,192 bytes of flash memory for programs. The Trinket contains bootloader code which occupies part of this. The bootloader assists in loading user programs from the Universal Serial Bus (USB) port. Adafruit has developed a custom bootloader based on the V-USB project. With the bootloader in flash memory, there is approximately 5,130 bytes of program memory for user programs. Random access memory (RAM) is used for program variables. The ATtiny85 has 512 bytes of RAM which seems like a minuscule amount compared to 4 gigabytes on a typical laptop. But in practice, this is often more than enough for many programs.

memory

Finally, the chip also contains 512 bytes of electrically erasable programmable read only memory (EEPROM). You can use this memory to store user data that remains even after Trinket is powered off. This is useful to save data such as setup information, state data, or critical readings. This memory can also be useful to store static information such as character strings a program might use, which otherwise would occupy precious program flash memory or RAM. Programmers must weigh using EEPROM for savings verses the additional code the compiler may add to manipulate data. Most programs do not use EEPROM.

Connectivity

The Attiny85 chip uses only six pins for input and output with two pins for power and ground. Atmel engineers cleverly assign multiple types of functionality to each pin, shown in Figure 1-5.

connectivity

In the design of the Trinket, Adafruit exposes much of the chip functionality. They added the ability to communicate over the USB serial port, as well as status lights and a reset button. The diagram in Figure 1-6 shows the Trinket 5V and the functionality onboard.

usb

The pins functions are listed in the following table:

table

table2

Three Volts or Five Volts?

The Trinket comes in two versions. One operates at 5 volts direct current (DC), the other at 3.3 volts DC. The functionality of each is nearly identical. The 5 volt version can run from USB power or from an input voltage of 5 to 16 volts. The 3.3 volt version can also run from USB power or an input voltage of 3.3 to 16 volts DC.

This provides a great deal of flexibility in powering a Trinket. Trinket may be powered from a wall-mounted DC power supply (like a cell phone charger type supply), of course. But it is also very suitable to being power from a wide range of batteries. This includes batteries such as a single 3.7 volt Lithium-Polymer (LiPo) battery, three 1.5 volt batteries in series (4.5 volts), four batteries in series (6 volts for regular cells, 4.8 volts for rechargables), even a 9 volt battery (although a 9 volt may not provide current for a long time). The size of the batteries (the ampere-hour rating of the LiPo, whether you use AAA, AA, C, or D size cells) determines how long a circuit may last.

The 3.3 volt version may be preferable when running off of a 3.7 volt LiPo rechargeable battery. Sensors that operate on a 3.3 volt signal level are easier to use with a Trinket 3V. The only limitation the Trinket 3V has over the Trinket 5V is the Trinket 3V can only run at a clock speed of 8 megahertz (MHz).

Many digital circuits operate at a signal level of 5 volts. Hooking a 5 volt circuit to a 3.3 volt input pin could damage the Trinket 3V’s ATtiny85. So for projects that must use 5 volt signal levels, the Trinket 5V is the best choice. The Trinket 5V can run at a clock speed of 8 MHz or, via a software switch, 16 MHz. Both Trinket 5V and Trinket 3V are used in projects in this book. You probably want to buy one of each for starters.

• Lady Ada herself gives a great overview of the Trinket in this video.

• Learn more about Getting Started with Adafruit Trinket at our Maker Shed.

Engineer, Maker, and innovator Mike Barela is a Senior Foreign Service Officer with the US Department of State. A graduate of both Whitman College and the California Institute of Technology in Electrical Engineering, he has worked at Hewlett-Packard, the NASA Jet Propulsion Laboratory, and Boeing. He has traveled the world, living in a number of countries providing security to American Embassies. An avid electronics enthusiast, he has worked on computers since the introduction of the PC. He rekindled his electronics and microcontroller interests, authoring a number of popular articles on using Arduino-compatible systems. This includes collaboration with Adafruit Industries on their popular Trinket microcontroller.