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, andavrdudefrom the command line.
Open Command Prompt.
Type:
avr-gcc --versionIf it shows the compiler version, installation is successful.
๐ฅ️ 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.
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 Pin | Function | Arduino Uno ISP Pin |
|---|---|---|
| Pin 1 (RESET) | RESET | D10 |
| Pin 4 (GND) | Ground | GND |
| Pin 5 (PB0) | MOSI | D11 |
| Pin 6 (PB1) | MISO | D12 |
| Pin 7 (PB2) | SCK | D13 |
| Pin 8 (VCC) | +5V | 5V |
๐ ️ 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.
Circuit Diagram
ATtiny13 LED Blink Code,
#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;
}


