ATtiny13 LED Blink Simulation in Proteus

 I have heard of ATtiny13 micrcontroller for a while now and today I simulated a hello world program with ATtiny13 microcontroller in Proteus. As you might know Hello world program in micrcontroller programming means to blink a LED. So, this is a AVR Microcontroller Programming for Beginners  guide. I used winavr compiler which can be downloaded for free. The advantages of using ATtiny microcontrollers are that they are small, cheap, energy-efficient, and easy to program via ISP, making them ideal for simple embedded projects, battery-powered devices, and space-constrained designs. They’re often chosen as a lightweight alternative to larger Arduino boards when only a few pins or basic functionality are needed. 

However, many beginners start programming the ATtiny13 using the Arduino language because it feels familiar and easy. While there are many advantages of using ATtiny13 microcontroller, there is also downside of using Arduino with Attiny. Most beginners might now know that you cannot use most of the Arduino libraries because they are too large for Attiny13 1KB flash memory. 

Compared to Arduino, it’s equally straightforward to use the WinAVR toolchain, which gives you direct control over registers and efficient C code compilation, write pure C code, compiled directly for AVR, Full control over registers, fuses, and optimization.

Step by step guide to install WinAVR is as follows.

๐Ÿ“ฅ How to Download and Install WinAVR

1. Download WinAVR

  • Visit the official SourceForge page: WinAVR on SourceForge

  • Download the latest stable release (WinAVR-20100110 is commonly used).

2. Install WinAVR

  • Run the installer and follow the prompts.

  • By default, it installs to C:\WinAVR-20100110.

  • It sets up environment variables so you can use avr-gcc, avr-libc, and avrdude from the command line.

3. Verify Installation
    • Open Command Prompt.

    • Type:

      avr-gcc --version
      
    • If it shows the compiler version, installation is successful.

After installation of WinAVR compiler, you also most likely want to use IDE for writing and uploading the code into the ATtiny13 chip. So here are some free IDE(Integrated Development Environment) for Attiny microcontroller.

๐Ÿ–ฅ️ IDEs You Can Use with WinAVR

  • Programmer’s Notepad (bundled with WinAVR) – lightweight editor with build integration.

  • Eclipse CDT with AVR plugin – more advanced, supports projects and debugging.

  • Atmel Studio (Microchip Studio) – official IDE, integrates with AVR-GCC toolchain.

  • VS Code – with AVR extensions, modern and customizable.

After you have downloaded WinAVR compiler and IDE, you need to write program and upload it. Here is the workflow for this step.

 Workflow

1. Write your C code (e.g., LED blink).
2. Compile with avr-gcc.
3. Generate .hex file.
4. Upload to ATtiny13 using avrdude and an ISP programmer (many use Arduino Uno as ISP).

ISP stands for In-System Programming.

It’s a method used to program microcontrollers (like the ATtiny13) directly while they are mounted in the circuit, without needing to remove the chip. Instead of using a separate programmer socket, you connect to the chip’s programming pins (MISO, MOSI, SCK, RESET, VCC, GND) and upload code via an external programmer such as an Arduino Uno running the ArduinoISP sketch.

So, if you are using the Arduino as ISP programmer then you have to interconnet Arduino and Attiny13 mcu in the following way.

ATtiny13 PinFunctionArduino Uno ISP Pin
Pin 1 (RESET)RESETD10
Pin 4 (GND)GroundGND
Pin 5 (PB0)MOSID11
Pin 6 (PB1)MISOD12
Pin 7 (PB2)SCKD13
Pin 8 (VCC)+5V5V

The circuit diagram shows how to interface Arduino and ATtiny13.

Arduino and ATtiny13 ISP interfacing

๐Ÿ› ️ Notes

  • RESET must be pulled low by the programmer to enter programming mode.

  • MOSI/MISO/SCK are the SPI lines used for communication.

  • VCC/GND provide power.

  • Add a 10 ยตF capacitor between RESET and GND on the Arduino Uno (when using it as ISP) to prevent auto-reset during programming.

In this work, try the ATtiny13 chip interactive pinout explorer which is free web tool that help you in pin planning such as the SPI pins.

Circuit Diagram

For this tutorial, the circuit for led blink is pretty simple. A LED with 270Ohm resistor is connected to the pin 5 of ATtiny13 microcontroller.

Attiny13 led blink circuit diagram

As you can see the Attiny is powered with 3.3V ans so this is a low power LED flasher with ATtiny13 micrcontroller.

ATtiny13 LED Blink Code,

The ATtiny13 LED Blink Code using winavr compiler is below.
#include <inttypes.h>
#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
    // Set PB0 (pin 5 on ATtiny13 DIP) as output
    DDRB |= (1 << PB0);

    while (1)
    {
        // Turn LED on
        PORTB |= (1 << PB0);
        _delay_ms(500);

        // Turn LED off
        PORTB &= ~(1 << PB0);
        _delay_ms(500);
    }

    return 0;
}

  
Below is video demo on simulation of ATtiny in Proteus:



In short, while Arduino IDE makes ATtiny programming beginner-friendly, WinAVR is equally easy and often more efficient for small chips like ATtiny13. It gives you direct control and avoids the overhead of Arduino libraries.

Related Tutorials

Post a Comment

Previous Post Next Post