WinAVR is a set of open source software development tools for C programming the AVR microcontroller family. It includes the GNU GCC compiler for C and the Programmers Notepad.
To learn programming in C you have to install WinAVR first. This small project let you make running leds. You need a attiny2312 microcontroller, eight LED's and 8 resistors of 150ohm.

Go to and download and install the latest version of the WinAVR package.

Programmers Notepad

The C code will be written using the Programmers Notepad, it is included in the WinAVR package.


You can use the  ATTiny2313 projects board and a small breadboard to build your C-projects on. You can buy it at To build the circuit you can use the LED board or use a small breadboard.  


Put the LED in the breadboard with the short leg on the resistor side. Use the 150-Ohm resistors to jumper to the ground strip. Use a flat cable and connect the wires to the beadboard. Plug in the flat-cable connector in the PORTB connector of the ATTiny2313 board. Below you see the schematic.

Blink a LED Tiny2313 sch

In the WinAVR main folder make a new sub folder called 'runningleds' for this project. 
Copy '../WinAVR/Samples/makefile' (notice that is has no extension) to the 'runningleds' folder. 
Open Programmers Notepad, click File, then click New, then click C/C++ and name it runningleds.c.  
Save it in the runningleds folder and type exactly as shown below: (or copy and paste it)

//programname: running leds
//Target : ATTiny2313
#include <avr/io.h>
#include <util/delay.h>

#define F_CPU = 20000000;

int main (void)

int i;
DDRB = 0xFF; // set port B for output


for(i = 1; i < 128; i = i*2)
PORTB = ~i;
for( i = 128; i > 1; i -= i/2)
PORTB = ~i;
return 1;


Click File and save 'runningleds.c' to the runningleds folder.

Open the file 'makefile' in your runningleds folder.
Change these lines to: 

MCU = attiny2313
FORMAT = ihex
TARGET = runningleds 

  • Save and close the file
  • Open Tools menu and click [WinAVR] Make all to make the runningleds.hex file.

WinAVR and Windows 8

if you use WinAVR with Windows 8 you can probably get an error during compiling.

Copy the msys-1.0.dlll file into the [WinAVR] utils\bin directory then the compiler will work like before. You can download the file on the downloads page of this article.