There are times when you need a small microcontroller to perform a singular simple task. You may only need a couple of pins of input and output. Although reaching for an Arduino board might come to mind first, a board often is overkill for such a simple task. Most of the features of the board that you paid a premium for go unused.

Sometimes these projects also have space and size restrictions which can make using an Arduino board impossible.

Trim the fat (and the cost!)

For simple tasks, consider using bare microcontroller ICs, like the Atmel (Microchip) AVR ATTiny13a. This 8-pin IC has a range of functionality spread out over 6 I/O pins. The 8-pin DIP package is pretty tiny. If you can work with surface mount components, the SOIC package is even tinier. Either can be purchased in bulk for under $1 each when purchased from Mouser or Digi-key.

ATTiny13a DIP and SOIC packages DIP package on the left with SOIC package on the right. Distance between the yellow lines is 1 inch

Features

ATTiny13a pinout diagram Pinout diagram from MCUDude, author of the Arduino core for the ATTiny13a

Above is the pinout diagram for the ATTiny13a. If you will be working in the Arduino platform, the “port” values would be less important to you.

Using only 6 data pins, there is an impressive array of features that are available:

  • 6 pins can be configured digital I/O pins
  • 4 pins can be configured for analog input pins
  • 3 pins can be configured for SPI serial communications
  • 2 pins can be configured for PWM output

Wow. All of this in an 8-pin DIP IC… for under $1!

UART serial communications

Noticeably missing is a hardware UART. Please keep this in mind if the serial monitor or other UART communications is a requirement for your project. If your project requires UART comms, there is hope, so read on!

Arduino platform support

So how does one write programs “bare chip?” Traditionally, programming of microprocessors or embedded systems usually involved proprietary compilers or programming platforms. For many people (myself included), there is a strong argument for staying in the Arduino Platform ecosystem: ease of use, strong community support, wealth of mature libraries, and being open source, just to mention a few. Thankfully, the good folks on MCUDude’s MicroCore project have developed an Arduino core for the ATTiny13A which brings Arduino support of most functions to the ATTiny13A.

Because there isn’t a hardware UART on the ATTiny13a, included with the MicroCore core is “bit-bang” software UART. It is a slim bit of code that brings basic UART capabilities to the ATTiny13a. There are limitations, however. Please refer to Serial support in the MicroCore documentation for details.

To set up the Arduino IDE, open your preferences and add

https://mcudude.github.io/MicroCore/package_MCUdude_MicroCore_index.json

to the list of Addtional Board Manager URLs.

Arduino board manager

The ATTiny13 will then be available as a selection for your sketch.

image of board selection

Flashing the chip

So how does one download (flash) a program to the “bare chip?” Obviously, there isn’t a USB connector or FTDI connector on the chip. Downloading (or flashing) a program requires an additional piece of hardware: an ISP programmer. Although there are commercially available ISP programmers for the ATTiny13a, if you have a spare Arduino around, it can act as the programmer.

Arduino as ISP Arduino Pro Mini as an ISP programmer for the ATTiny13A. I use a ZIF socket for mine so I can easily insert and remove the ATTiny13a IC without risking breaking or bending pins.

For the setup above, I used:

Of course, if you use a Mini you’ll also need and FTDI adapter or cable (#ad).

There is an awesome tutorial on how to set this up on the Arduino Project hub written by Tauno Erik.

The best part about making your own is that once you’re done programming the ATTiny13a, you can disassemble the programmer and use the parts for something else.

Limited memory

The ATTiny13a sports 1 whole kilobyte of memory. Yes, only 1K. You have to be lean and optimize the heck out of your code.

Sum-up

ATTiny13a DIP, SOIC and Breadboard

Pros:

  • Under $1!
  • Tiny
  • 6 multifunction I/O pins
  • Arduino support
  • Available in through-hole DIP and surface mount SOIC packages

Cons:

  • No hardware UART
  • Only 1K of program memory
  • Needs to be programmed with an ISP

The Takeaway

The takeaway is that the ATTiny13a is the perfect choice where a you are working with space considerations and a rich feature set is not required for your project. The low price point makes these especially suitable for applications where your device might get damaged or lost, as the sub $1 price tag makes these on the verge of “disposable.”

In case you missed it

As of this writing, there seems to be a shortage of ATTiny13a chips. Check the web sites of suppliers like Mouser or Digi-key for expected availability. To purchase from a smaller supplier, try here on Amazon (#ad). Expect to pay around $1.50 per chip for smaller quantities or from smaller suppliers.

Level up!

For inspiration check out Łukasz Podkalicki’s round-up of his neat-o projects using the ATTiny13. With a little creativity and ingenuity, this little chip can go a long way.

If you are interested in a deep dive into programming the Atmel (Microchip) AVR ATTiny13a (or other AVR) microcontroller, check out these books:

Support me with a dumpling.

If you’ve enjoyed this post, please support me with a dumpling :)

Lastly

As an Amazon Associate I earn from qualifying purchases. Your support helps me to continue to write useful and meaningful content!