This post is intended to assist you getting started with AVR DEVELOPMENT SELF LEARNING KIT.

It supports 40 pin AVR ICs like ATMEGA 16 /32 & a ZIF socket is provided to host the chip.All PORT pins are extended with berg pins for easy connections with peripherals.

For Analog input testing 2 nos variable pot are provided & for testing Digital inputs 4 nos switches are provided.A 4×4 keypad matrix is on board.

4 NOS 7 SEGMENT DISPLAY with driver circuit is provided.Other features include , EEPROM 24C16 , RTC  DS1307, UART MAX232 , MOTOR DRIVER ULN2003. An LCD can be plugged with the port provided.

An ISP connector accepts USBASP programmer through a 10 pin FRC Header.




Download sample code ,WINAVR , USBASP DRIVER, AVRPAL.NET from HERE

Watch this video for details of installing USBASP driver & getting started with AVR Kit.


Connect the USBASP AVRDUDE with ISP connector & USB cable to your port on PC.Power up the kit with the 12v/1A adapter provided.Once the driver is installed , under Device manager USBASP appears

Image 1


WINAVR is used to develop C code & upload HEX file on to the Target chip.WINAVR has a PROGRAMMERS NOTEPAD which is the IDE we use to develop code.

MFILE in WINAVR helps us to create the rules for making.This MAKE FILE must be saved within the same folder where you saved the C file.Compared to ATMEL STUDIO ( a HUGE Download) WINAVR is small & powerful.

Image 2


To start with create an empty Folder , say LED ,inside your drive.Here is where we’ll be saving all our files.

Open PROGRAMMERS NOTEPAD & type in the following C code.

Save the file as LED.c inside the folder we created earlier.

Do not forget the .C Extension.


#include <avr/io.h>
#include <util/delay.h>

int main(void)
DDRC = 0xFF; //Makes PORTC  as Output

while(1) //infinite loop
PORTC = 0b00000001 ; // LED ON at PC0
_delay_ms(100); // delay

PORTC = 0b00000000 ; // LED OFF at PC0
_delay_ms(100); // delay



The code starts with PREPROCESSOR Directives

# include <avr/io.h>     defines all PORT names & pins of AVR

# include <util/delay.h>   defines the delay timing

Then starts the MAIN function under which we first declare PORTC pis as all OUTPUT.

Notre that in AVR we use 1  to declare OUTPUT & a 0 to declare as INPUT (REVERSE TO PIC programming)

I/O Pins of AVR has 2 to 3 functions & each PORT is associated with 3 REGISTERS

For e.g PORTC is associated with 3 registers

DDRC —>  DATA DIRECTION REGISTER  Configures   Port as INPUT (0) or OUTPUT  (1)

PORTC —> Write Data to PORT Pins

PINC   —> READ DATA from PORT Pins


Next is the indefinite loop while(1)

Inside which we make PORTC bit 0 as HIGH & all other pins LOW.

This is achieved by Binary notation

PORTC = 0b00000001 ;

After a delay


we make PORTC bit 0 as LOW

PORTC = 0b00000000 ;

Now we need to create the RULES for Making which is done through MFILE of WINAVR

Open MFILE.Click on MakeFile

Select MCUtYPE as ATmega16

Port as usb

Programmer as usbasp.


Image 5


Under Progammer usbasp  is not listed. Select any other type like STK500 & then click on Enable Editing.

Now you’re allowed to make changes.Type in usbasp against Programmer.

Image 9

Scroll up to locate TARGET=main

Change this main to your C file name without any .c extension

Image 6

Save the Makefile inside the same folder where your C code is stored.

Image 7

Now click on MAKE ALL to generate HEX file.

Tools –> Program to load the HEX file automatically on to the target chip.

Image 4

Now let us see how to use the BITWISE OPERATORS in C code

To improve code clarity & to leave generation of  1s & 0s to the compiler we use SHIFT OPERATORS.

For e.g  instead of writing 0b0010 0000

we can write    0b0000 0001 <<5

or simply         1<<5     This is left shift operation.

0B0001 0000 << 3   will result 0B1000 0000    SHIFTING LEFT 3 TIMES

To generate  0B1110 1111    SHIFT FIRST & THEN INVERT IT




To set an individual BIT we use the OR OPERATOR  |

e.g   DDRD = 0b0000 0001    To SET bit 4

SHIFT it 4 times to get 0b0001 0000

OR this result with DDRD Register

DDRD = DDRD | (0b00000001 <<4);

DDRD = DDRD | (1<<4); 

or you  can write simply   DDRD |= (1<<4);

Only BIT 4 is SET & other bits not affected.

You can also define a constant & use it

# define LED 4

DDRD |= (1<<LED);



e.g  DDRD = 0b0101 0101;

To clear the bit 2 (shown in bold letter above)

start with binary no.    0b0000 0001

Left SHIT 2 TIMES  to get  0b0000 0100

Invert this to get    0b1111 1011

use the & OPERATOR with DDRD Register


#define switch 2

DDRD &= ~ (1<< SWITCH);



To check status of 4th bit of PIND Register

Notice the use of PIN Register here

#define switch 4

status = (PIND & (1<< SWITCH) !=0);




To toggle 4th bit of PORT D

PORTD = 0B0000 0000

START with 0b0000 0001   shift by 4 times to get

0b0001 000


#define LED 4

PORTD ^= (1<< LED);

Every time this statement is executed the LED changes state


Following is the code with BITWISE operators implemented.

We use OR EQUAL LEFT SHIFT to declare portC as output

Inside while loop PORTC BIT 0 is made ON & then OFF after a delay , which is repeated for ever.


#include <avr/io.h>
#include <util/delay.h>

int main(void)
DDRC |= (1 << PC0); //Makes PORTC PC0 Pin22 as Output

while(1) //infinite loop
PORTC |= (1 << PC0); //Turns ON LED at PC0 or PORTC=0b00000001
_delay_ms(100); // delay

PORTC &= ~(1 << PC0); //Turns OFF LED or PORTC=0b00000000
_delay_ms(100); // delay



cooltext753793315    cooltext753790696