ATtinny85 Getting Started Tutorial, and its programming with Arduino

(Last Updated On: April 29, 2021)

ATtinny85 microcontroller:

ATtinny85 Microcontroller– ATtinny85 can be a best choice when planning to reduce the project size and development cost. With the ATtinny85 Microcontroller you can do amazing things as it can be programmed. You can program this beautiful piece of hardware using your Arduino Uno boards.  How you can program an ATinny85 using an Arduino Uno with some jumper wires but before that let’s just understands some basic behind ATtinny85. ATtinny85 is an 8-bit AVR microcontroller based on RISC CPU. It has eight pins and fall under category of low powered microcontrollers. It has programmable watchdog timer and 10 bit converter which make it suitable for many sensor based projects. It’s programmable memory is 8 kilobyte while the EEPROM and RAM contain memory space of around 512 bytes. It has 6 I/O pins which have internal pull-up resistors and its operational voltage is between 1.8 volt to 5 volts.

ATtinny85


Features:

  • High Performance, Low Power AVR® 8-Bit Microcontroller
  • Advanced RISC Architecture

– 120 Powerful Instructions – Most Single Clock Cycle Execution

– 32 x 8 General Purpose Working Registers

– Fully Static Operation

  • Non-volatile Program and Data Memories

– 2/4/8K Byte of In-System Programmable Program Memory Flash (ATtiny25/45/85)

Endurance: 10,000 Write/Erase Cycles

– 128/256/512 Bytes In-System Programmable EEPROM (ATtiny25/45/85)

Endurance: 100,000 Write/Erase Cycles

– 128/256/512 Bytes Internal SRAM (ATtiny25/45/85)

– Programming Lock for Self-Programming Flash Program and EEPROM Data

Security

  • Peripheral Features

– 8-bit Timer/Counter with Prescaler and Two PWM Channels

– 8-bit High Speed Timer/Counter with Separate Prescaler

2 High Frequency PWM Outputs with Separate Output Compare Registers

Programmable Dead Time Generator

– USI – Universal Serial Interface with Start Condition Detector

– 10-bit ADC

4 Single Ended Channels

2 Differential ADC Channel Pairs with Programmable Gain (1x, 20x)

Temperature Measurement

– Programmable Watchdog Timer with Separate On-chip Oscillator

– On-chip Analog Comparator

  • Special Microcontroller Features

– debugWIRE On-chip Debug System

– In-System Programmable via SPI Port

– External and Internal Interrupt Sources

– Low Power Idle, ADC Noise Reduction, and Power-down Modes

– Enhanced Power-on Reset Circuit

– Programmable Brown-out Detection Circuit

– Internal Calibrated Oscillator

  • I/O and Packages

– Six Programmable I/O Lines

– 8-pin PDIP, 8-pin SOIC and 20-pad QFN/MLF

  • Operating Voltage

– 1.8 – 5.5V for ATtiny25/45/85V

– 2.7 – 5.5V for ATtiny25/45/85

  • Speed Grade

– ATtiny25/45/85V: 0 – 4 MHz @ 1.8 – 5.5V, 0 – 10 MHz @ 2.7 – 5.5V

– ATtiny25/45/85: 0 – 10 MHz @ 2.7 – 5.5V, 0 – 20 MHz @ 4.5 – 5.5V

  • Industrial Temperature Range
  • Low Power Consumption

– Active Mode:

1 MHz, 1.8V: 300 μA

– Power-down Mode:

0.1μA at 1.8V



ATinny85 Pinout:

ATtinny85

Programming ATtinny85 microcontroller:

For programming ATtinny85 microcontroller, first you need to download the core files.

Step 1:

Now in order to add ATtinny85 board to Arduino IDE we will first open the Arduino IDE. Then in the Arduino IDE click on the file and in file click on the preference.

ATtinny85

Step 2:

When we click on the preference a dialog box will appear:

ATtinny85

Now in the additional boards manager paste the following link:

ATtinny Board Manager URL Link:

https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json

After pasting the link, click on the ok.


Step 3:

Now in step 3 go to tools and in tools select the board and then click on the board manager.

Step 4:

In board manager different types of board will appear now select the attiny and click on the install.

ATtinny85

Step 5:

Once the ATtinny is installed, close your Arduino IDE and open again. Now the attiny board is installed in order to open it we will go to the tool then select the board and then select the attiny microcontroller in which we will select the ATtinny 25/45/85

ATtinny85

Step 6:

Now open the examples and select the Arduino ISP the code will appear.

ATtinny85


Code:

Upload the Arduino ISP sketch which can be found an example into your Arduino Uno board. you can use any Arduino board but I am using Arduino Uno, after uploading this sketch your Arduino will act as a programmer.


ATtinny Connection with Arduino, Circuit diagram:

Now we will connect the ATtinny85 with the Arduino. Connect the pin eight of ATtinny85  to five volts of the Arduino UNO. Connect pin seven of the ATtinny85 to pin 13 of the Arduino Uno. Connect pin six of the ATtinny85 to pin 12 of the Arduino UNO. Connect pin 5 of the ATtinny85 to pin 11 of the Arduino UNO. Connect pin one of the ATtinny85  to pin 10 of the Arduino UNO and finally, pin four of the ATtinny85 Microcontroller to the ground pin of the Arduino UNO. Also do not forget to add 10uf capacitor with reset and ground.

ATtinny85

For the programming we just need to put the ATtinny85 into the depth socket and then connect the Arduino UNO with our computer. Now after wiring go to the Tools menu and select ATtinny85:

ATtinny85

Now change the clock to 8 megahertz:

ATtinny85

Select the port change the programmer as Arduino as ISP

ATtinny85

Then click on the burn bootloader you only have to burn the bootloader once.

ATtinny85

Once I have connected an LED to pin five of the ATtinny85 which is pin d0.

ATtinny85



Code:

Now after writing the code in the sketch we will upload the code to the Arduino as upload using programmer.

ATtinny85

After uploading the program the led will start blinking.

ATtinnny85 Based Project:

Clap ON / OFF circuit using ATtinny85 microcontroller:

Now to make the this circuit we will repeat the same steps to program the ATtinny85 microcontroller with Arduino as discussed above and upload the code:

ATtinny85


After uploading the code to the ATtinny85 microcontroller we will remove the ATtinny85 microcontroller from the Arduino. Now we will connect the ATtinny85 with sensor and relay module.

  • Connect the pin number 7 of the ATtinny85 with the out of the sound sensor
  • Connect the ground pin number 4 of the ATtinny85 with the ground of the sound sensor
  • Connect the battery positive terminal with pin number 8 of the ATtinny85 and with VCC of the relay and sound sensor
  • Connect the ground of the relay with the ground of the ATtinny85 which is pin number 4.

Now the circuit is completed and if we connect a bulb or other appliance with the relay it will turn on and off with the clap.

 

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply