how to program ATTINY13

How To Program ATTiny13 / ATTiny13A using Arduino

Posted on

How to program ATtiny13 – If you need a microcontroller for a simple use, the ATtiny microcontroller is the choice. One is ATtiny13. Not much different from ATtiny85, with a cheaper price than ATtiny13 it can save a program of 1KB. With the size of a flash memory the size of 1KB is enough if you make a simple program. For example, turning on the lights with a motion sensor, turning on the lights with an infrared remote, opening the door with a password, making flash lights and others.

ATtiny13 has the following specifications:

  • 8-Bit Microcontroller
  • External frequency up to 20 MHz
  • Internal frequency up to 9.6 MHz
  • 1KB Flash Memory
  • 64 Byte EEPROM
  • 64 Bytes SRAM
  • 4-Channel 10-bit ADC
  • 8-Pin with 6-Pin I / O
  • Operating voltage starts from 1.8V – 5.5V
  • Learn more.

The ATtiny13 Pin scheme is as follows:

attiny13 pinout

How to program ATtiny13, you can use an Arduino Uno, Nano, Micro and others that support Arduino as ISP. The SPI pins used are PB2 (SCK), PB1 (MISO), PB0 (MOSI) and PB5 (Reset).

1. Install Library

To be able to install the library there are two ways, through the Board Manager on the Arduino IDE or manually install at Arduino Folder.  This library only supports Arduino IDE version 1.6.4 or above.

a. Install through the Board Manager

  • Open the Arduino IDE Software
  • Go to File > Preferences

In the Additional Boards Manager URLs, enter the link below then click OK:

how to program attiny13

  • Click Tool > Board > Boards Manager
  • Please wait for the file to be downloaded.
  • Look in the search field with the name MicroCore, then click Install.
  • After the board is installed, friends will see a list of these boards as shown in this picture.
    Cara Install Attiny13
  • The installation was successful.

b. Manual Installation

  • Download this library  first, Download the ATtiny13 Library.
  • Then extract the ZIP file.
  • Move the extract folder to / Document / Aduino / hardware.
    how to program attiny13
  • If there is no hardware folder, please create it first.
  • Open the Arduino IDE, select menu Tools > Board (see the two images above).
  • Installation complete.
Read other articles  Synchronize DS3231 RTC with PC

2. Schematic

Follow the schematic below for how to program ATtiny13 . with pin configuration:

Cara program ATtiny13

Cara program ATTINY13

3. Program

a. Make Arduino an ISP

  • Open the Arduino IDE
  • Select File > Example > 11. ArduinoISP > Arduino ISP
  • Select the Tools > Board > Arduino / Genuine Uno
  • Select the Programmer > AVRISP mkll
  • Then click Upload
  • Finish, go to point 3.2.

b Burn Bootloader

Burn Bootloader program is quite important and only once at the beginning. This is necessary so that ATtiny13 will define all the internal settings of the ATtiny13 such as the value of the frequency used. If ATtiny13 is not on the bootloader, the performance is not suitable. For example, we set the delay of the ATTiny13 program to turn on and turn off the light for 1 second. If there is no bootloader, the program can run with 1.5 or 2 seconds delay. This will affect all ATtiny13 performance.

  • Select the Tools > Board > ATtiny13 menu
  • Select the Tools > Programmer > Arduino as ISP menu
  • Select the Tools > Burn Bootloader
  • Finish

c. Upload Main Program

  • Select File > Examples > 01. Basics > Blink
  • Change the word LED_BUILTIN, follow this program:
led = 3;
void setup() {
pinMode(led, OUTPUT);
void loop() {
digitalWrite(led, HIGH);
digitalWrite(led, LOW);
  • Connect an LED to the PB3 pin as shown below.
  • If it blinks for 1 second, then our program has succeeded.


One thought on “How To Program ATTiny13 / ATTiny13A using Arduino

Leave a Reply

Your email address will not be published. Required fields are marked *