Introduction to the ATtiny85 Microcontroller

The ATtiny85 is a tiny but powerful microcontroller chip that has become increasingly popular among hobbyists, makers, and professionals alike. Manufactured by Atmel Corporation, which is now a part of Microchip Technology, the ATtiny85 is a low-cost, low-power device that packs a lot of functionality into a Attiny core small package.

Despite its small size, the ATtiny85 is capable of running a wide range of applications and is often used in projects that require real-time processing, low power consumption, and a small form factor. Its simple architecture and ease of use make it an ideal choice for beginners who are just getting started with microcontrollers and embedded systems.

Another important feature of the ATtiny85 is its 8-bit architecture, which allows it to process data in 8-bit chunks. This limits the range of values that it can process but also makes it more efficient and less power-hungry than 16-bit or 32-bit microcontrollers. The ATtiny85 belongs to the AVR controller category, which is based on Harvard architecture and includes separate locations for program and data memory.

In this article, we will explore some of the key features of the ATtiny and how they can be used in various applications. We will also discuss how to upload code to the ATtiny85 and some of the challenges that beginners may face when working with this microcontroller. By the end of this article, you will have a better understanding of what the ATtiny85 is capable of and how you can use it in your own projects.

If this sounds interesting to you and you'd like to request a demo or learn more, please contact sales.

Contact Sales
| ATtiny85 Features | | | :=== | :=== | | No. of Pins | PDIP: 8pins / QFN: 20pins | | CPU | RISC 8-Bit AVR | | Operating Voltage | 1.8 to 5.5 V | | Program Memory | 8K | | Program Memory Type | Flash | | RAM | 512 Bytes | | EEPROM | 512 Bytes | | ADC Number of ADC Channels | 10-Bit 4 | | Comparator | 1 | | Packages | PDIP(8-Pin) SOIC(8-Pin) TSSOP (8-Pin) QFN/MLF (20-Pin) | | Oscillator | up to 20 MHz | | Timer (2) | 8-Bit Timers | | Enhanced Power on Reset | Yes | | Power Up Timer | Yes | | I/O Pins | 6 | | Manufacturer | Microchip | | SPI | Yes | | I2C | Yes | | Watchdog Timer | Yes | | Brown out detect (BOD) | Yes | | Reset | Yes | | USI (Universal Serial Interface) | Yes | | Minimum Operating Temperature | -40 C | | Maximum Operating Temperature | 125 C |

Does ATtiny85 have analog pins?

Yes, ATtiny85 has two analog input pins, namely PB2 (ADC1) and PB3 (ADC3). These pins can be used to read analog signals from external sensors or other devices. It's one of the key features of the ATtiny85 is its analog input pins, which enable it to read analog signals from external sensors or other devices. This makes it suitable for applications that require high precision, such as temperature sensing and audio processing.

The analog-to-digital converter (ADC) in ATtiny85 has a resolution of 10 bits, which means that it can convert analog signals into digital values with a range of 0 to 1023. This makes it suitable for applications that require high precision, such as temperature sensing and audio processing.

How many bits is ATtiny85?

ATtiny85 is an 8-bit microcontroller, which means that it can process data in 8-bit chunks. This limits the range of values that it can process, but also makes it more efficient and less power-hungry than 16-bit or 32-bit microcontrollers.

The 8-bit architecture of ATtiny85 means that it can perform simple arithmetic and logic operations quickly and efficiently. However, it may not be suitable for applications that require complex mathematical calculations or high-speed data processing.

Is ATtiny85 a microcontroller?

Yes, ATtiny85 is a microcontroller. It is a small, integrated circuit that contains a processor core, memory, and a variety of peripherals. It is designed to be used in embedded systems and can be programmed to perform specific tasks.

The microcontroller architecture of ATtiny85 makes it ideal for use in applications that require real-time processing, such as sensor data acquisition, motor control, and audio processing. It is also suitable for applications that require low power consumption and a small form factor.

This module comes with software select power saving modes that are very helpful for the applications that operate with minimum power.

Like other controllers introduced by the Microchip, this module comes with 10-bit ADC converter that houses 4 analog channels that help in sensor interfacing and converting analog signals to digital ones.

This tiny chip is available in four packages called PDIP, SOIC, TSSOP, and QFN where first three come with 8-pin interface while the last one contains 20 pins.

Mini development board: ATtiny85 can be used as small development board which is a great way to jump into microcontroller electronics.

ATtiny85 Main Core Functions

ATtiny85 can perform a number of functions on a single chip. Some pins come with an ability to employ more than one functions.

Timers

One of the powerful features of the ATtiny85 microcontroller is its ability to function as a timercounter.. The ATtiny85 has two 8-bit timers (Timer0 and Timer1) that can be used for a variety of timing applications. These timers can operate in several different modes, including:

  • Normal mode: In this mode, the timer simply counts up from 0 to 255 and then starts over. This mode is useful for generating delays and for basic timing applications.
  • CTC (Clear Timer on Compare) mode: In this mode, the timer counts up to a specified value and then resets to 0. This mode is useful for generating precise delays and for measuring time intervals.
  • PWM (Pulse Width Modulation) mode: In this mode, the timer generates a square wave with a variable duty cycle. This mode is useful for controlling the speed of motors and for generating audio signals.

In addition to the timers, the ATtiny85 also has a built-in watchdog timer that can be used to reset the microcontroller if it becomes stuck or unresponsive. This feature is especially useful in safety-critical applications where the microcontroller needs to be able to recover from errors and prevent system failures.

SPI Communication

ATtiny85 comes with a serial peripheral interface (SPI) that is mainly used for communication between the microcontroller and other peripheral devices such as SD cards, sensors, and shift registers. It incorporates separate clock and data lines with the addition of a select line to pick the required device for communication. This communication allows both connected device to lay out the same path of communication under one communication protocol.

I2C Communication

I2C protocol is added in the device that is mainly two-wire protocol used to connect low-speed devices like ADC and DAC converters, I/O interfaces and microcontrollers. The two wires, known as Serial Clock (SCL) and Serial Data (SDA), are the main part of this communication protocol. The SCL line behaves like a clock signal that is generated by the master device and synchronizes the data transfer between the devices. While the SDA line is used to carry the required data.

BOD or Brown out reset

The BOD is a very useful function that helps in resetting the controller once the Vdd (voltage supply) drops below a brownout threshold voltage. The multiple voltage ranges are provided to secure the module once the power drops at the voltage supply line.

Interrupt

The interrupt plays a vital role in an emergency which puts the main function on hold and executes the required instructions that are necessary at that time. Once the interrupt is executed the running code puts the controller back to the main program.

ADC Converter

ADC module is a valuable addition in the device that makes it compatible with the sensors. It is a 10-bit module that contains 4 channels which are little less than the number of channels available on the modules introduced by Microchip that, more or less, come with 7 or 12 channels.

Microphone sinewave dislay: ATtiny85 can be used to generate and manipulate sound in various audio applications.

In addition to these applications, ATtiny85 can also be used in various DIY projects, hobbyist electronics, and educational projects. Its simplicity and ease of use make it a great choice for beginners who are learning about microcontrollers and embedded systems.

ATtiny85 available packages

The ATtiny85 comes in various packages, including:

  1. 8-pin DIP (Dual Inline Package): This is the most common package for the ATtiny85, and it has 8 pins that can be inserted into a breadboard or socket.
  2. 8-pin SOIC (Small Outline Integrated Circuit): This package has the same pinout as the DIP package, but it is smaller and designed for surface-mount applications.
  3. 8-pin MLP (Micro Leadframe Package): This is a surface-mount package that is even smaller than the SOIC package.
  4. 20-pin QFN (Quad Flat No-Lead): This package has a low profile and no leads, which allows for high-density circuit designs.

ATtiny85 Pinout

ATtiny85 PDIP-8 Package Pinout

Following table shows the pin description that will help you understand the major functions associated with each pin.

| Pin# | Name | Description | | :== | :== | :== | | 1 | PB5 PCINT5 RESET ADC0 dW | I/O Bidirectional pin Interrupt Reset Analog Channel 0 Define Word | | 2 | PB3 PCINT3 XTAL1 CLKI OC1B ADC3 | I/O Bidirectional pin Interrupt Crystal Oscillator Pin 1 Clock Analog Channel 3 | | 3 | PB4 PCINT4 XTAL2 CLKO OC1B ADC2 | I/O Bidirectional pin Interrupt Crystal Oscillator Pin 2 Clock Analog Channel 2 | | 5 | PB0 MOSI DI SDA AIN0 OC0A OC1A AREF PCINT0 | I/O Bidirectional pin SPI Serial Data (I2C) Analog Input Compare Register Voltage Reference Interrupt | | 6 | PB1 MISO DO AIN1 OC0B OC1A PCINT1 | I/O Bidirectional pin SPI Serial Data (I2C) Analog Input Compare Register Interrupt | | 7 | PB2 SCK USCKSCLADC1T0 PCINT2 | I/O Bidirectional pin Serial Clock Line (I2C) Analog Channel 1 Timer 0 Interrupt | | 4 | GND | Ground Pin | | 8 | VCC | Voltage Supply Pin |
ATtiny85 QFN-20 Package Pinout

ATtiny Memory

The memory of this little toy is designed and based on Atmel's high-density technology that is basically non-volatile in nature. The Program Memory can be reprogrammed through SPI serial interface using two ways i.e. On-chip boot code or non-volatile memory programmer. The main program execution is mainly done inside CPU that plays a vital role to access memories and perform calculations on the basis of the number of instructions incorporated into the controller. This module falls under the category of AVR controllers that are based on Harvard architecture and come with separate locations reserved for both program and data memory.

  • ROM Read only memory: The ATtiny85 microcontroller has a total of 8KB of flash memory for storing program code. This memory is non-volatile, which means that it retains its contents even when power is removed from the device. The flash memory is organized into 8K bytes, with each byte being individually addressable.
  • RAM Random access memory: In addition to flash memory, the ATtiny85 also has 512 bytes of SRAM (Static Random Access Memory), which is used for storing data during program execution. Unlike flash memory, SRAM is volatile, which means that it loses its contents when power is removed from the device.
  • EEPROM: The ATtiny85 also has 512 bytes of EEPROM (Electrically Erasable Programmable Read-Only Memory), which is non-volatile memory that can be used for storing data that needs to be retained between power cycles. EEPROM memory is accessed using special instructions and is slower than SRAM, but it can be written to and erased multiple times without wearing out.
LED controllers: ATtiny85 can be used to control the brightness and color of LEDs in various lighting applications.

How do I upload codes to ATtiny85?

To upload codes to ATtiny85, you need a avr programmer device that can communicate with the chip. There are several programmer devices that are compatible with ATtiny85, such as USBasp, Arduino as ISP, and Atmel AVRISP mkII.

Once you have the programmer device, you can connect it to your computer and the ATtiny85 chip using a breadboard or a custom PCB. You will also need to install the appropriate software, such as AVRDUDE or the Arduino IDE.

To upload the code to ATtiny85 using AVRDUDE, you will need to enter the appropriate commands in the command prompt or terminal window. For example, the command to upload a hex file to ATtiny85 using USBasp would be: 

avrdude -c usbasp -p attiny85 -U flash:w:myprogram.hex

There are many compilers available for compiling the code in the AVR microcontroller. Some are better than others. Before you pick some compiler for your controller, make sure it is easy to use and stand fit for your needs and requirements.

  • ImageCraft is good option to start with that has made a decent place in the market but lack of GUI features make this compiler difficult to handle where editor and project management are quite daunting and can put you in a total stall in the start.
  • CodeVision is another easiest compiler that comes with CodeWizard and helps in starting a new project sooner than later. Also, it is highly economical.

Alternatively, you can use the Arduino IDE to upload the code to ATtiny85. To do this, you will need to install the ATtiny core for Arduino and select the appropriate board and programmer settings. You can then write your code in the Arduino IDE and upload it to ATtiny85 using the standard upload button.

Tiny Motor Control board: ATtiny85 can be used to control the speed and direction of small motors in robotics and other applications.

Connecting ATtiny85 with Arduino uno as your programmer

| Arduino Pin | ATtiny85 Pin | | :== | :== | | 10 | 1 | | 11 | 5 | | 12 | 6 | | 13 | 7 | | +5V | 8 | | GND | 4 |

Tiny things can work wonders if used a proper way. Both ATtiny85 and Arduino uno, when connected, can easily drive automation in your project and help in executing the number of instructions. You can connect ATtiny85 with the Arduino following way.

It is important to note that programming ATtiny85 can be a bit challenging for beginners, as it requires some knowledge of electronics and programming. However, there are many tutorials and resources available online that can help you get started. Once you get the hang of it, programming ATtiny85 can be a fun and rewarding experience.

In conclusion, the ATtiny85 microcontroller is a versatile and powerful device that packs a lot of functionality into a small package. Despite its modest size, it is capable of running a wide range of applications and can be used in projects that require real-time processing, low power consumption, and a small form factor.

Whether you are a beginner who is just getting started with microcontrollers or a seasoned professional looking for a compact and efficient solution for your next project, the ATtiny85 is definitely worth considering. With its analog input pins, 8-bit architecture, and built-in flash, SRAM, and EEPROM memory, it provides a good balance of features that make it suitable for a wide range of applications.

So, if you are looking for a microcontroller that is small, efficient, and powerful, be sure to check out the ATtiny85. With its simplicity and ease of use, it is a great way to get started with embedded systems and explore the world of microcontrollers.

For more details and specifications, check out ATtiny85 Datasheet.

Profile avatar of the blog author

Jharwin Barrozo

Jharwin is an electronics engineer mainly focused on satellites. He built his own ground station using Flux to monitor RF activities on the International Space Station. Find him on Flux @jharwinbarrozo

Go 10x faster from idea to PCB
Flux is an all-in-one EDA. Use re-usable blocks, scripting, and a library you don’t have to manage to dramatically reduce the time it takes to go from idea to prototype.
Illustration of sub-layout. Several groups of parts and traces hover above a layout.
Illustration of sub-layout. Several groups of parts and traces hover above a layout.
Flux is a better way to build PCBs
Go 10x faster from idea to PCB by reducing busy work, never starting from scratch, and keeping your team in sync. All from the browser.
Screenshot of the Flux app showing a PCB in 3D mode with collaborative cursors, a comment thread pinned on the canvas, and live pricing and availability for a part on the board.
Flux is a better way to build PCBs
Go 10x faster from idea to PCB by reducing busy work, never starting from scratch, and keeping your team in sync. All from the browser.
Screenshot of the Flux app showing a PCB in 3D mode with collaborative cursors, a comment thread pinned on the canvas, and live pricing and availability for a part on the board.
Flux is a better way to build PCBs
Go 10x faster from idea to PCB by reducing busy work, never starting from scratch, and keeping your team in sync. All from the browser.
Screenshot of the Flux app showing a PCB in 3D mode with collaborative cursors, a comment thread pinned on the canvas, and live pricing and availability for a part on the board.
Flux for Enterprise
Learn how Fortune 500s are revolutionizing hardware design at scale with AI.
Flux for Enterprise
Join leading Fortune 500s and over 300k hardware engineers revolutionizing the way they build PCBs with AI
Flux for Enterprise
Join leading Fortune 500s and over 300k hardware engineers revolutionizing the way they build PCBs with AI