You have no items in your shopping cart.

Subtotal: 0.00

How to Interface 7SEG with AVR Development Board

AVR Development board

The AVR Development board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports In-system programming (ISP) which is done through Parallel/Printer port.

ATMEL’s AVR (Atmega8535), AVR Development Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of High speed 8-bit Microcontrollers.

Seven Segment Display

A seven segment display is the most basic electronic display device that can display digits from 0-9. The most common configuration has an array of eight LEDs arranged in a special pattern to display these digits. They are laid out as a squared-off figure ‘8’.

Interfacing Seven Segment Display

Fig. 1 shows how to interface the seven segments with microcontroller. A seven segment is generally available in ten pin package. While eight pins correspond to the eight LEDs, the remaining two pins (at middle) are common and internally shorted. These segments come in two configurations, namely, Common cathode (CC) and Common anode (CA).

Fig. 1 Interfacing 7segment to Microcontroller


Interfacing Seven Segment with AVR Development

We now want to display a four digit number in AVR Development board by using seven segment displays. The seven segment display is connected with ARV microcontroller.

In AVR Development Kit, 4 nos. of common anode seven segment displays are controlled by seven segment drivers.

Pin Assignment with AVR






Connect PORTB with CN2 via FRC Cable.

CN2 is at Seven Segment Section

Digits will be incrementing

from 0 to 9999



























Circuit Diagram to Interface 7 segment with AVR Development

Source Code

The Interfacing seven segment displays with AVR program is very simple and straight forward, which display a four digit number in seven segment display .The C programs are developed in CodeVisionAVR. Here we are increment a counter and display this value loaded into seven segment driver in AVR Development board

C Program to 7 Segment Display using AVR


Title : Program to Seven Segment display


#include <mega8535.h> #include <delay.h> #define CNTRL PORTC #define DATA PORTB int x; unsigned char thou=0,hun=0,ten=0,single=0; void send_seg(unsigned char,unsigned char,unsigned char,unsigned char); unsigned char a[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; unsigned char n=1; void main() { DDRB =0xff; DATA =0x00; DDRC =0xff; CNTRL=0x00; while(1) { if(x == 150) { x=0; single++; if(single>9) { single=0; ten++; if(ten>9) { ten=0; hun++; if(hun>9) { hun=0; thou++; if(thou>9) thou=0; } } } } x++; send_seg(thou,hun,ten,single); } } void send_seg(unsigned char thou,unsigned char hun,unsigned char ten,unsigned char single) { if(n==1) { CNTRL=0x04; DATA=a[single]; n=2; delay_ms(5); } else if(n==2) { CNTRL=0x08; DATA=a[ten]; n=3; delay_ms(5); } else if(n==3) { CNTRL=0x10; DATA=a[hun]; n=0; delay_ms(5); } else { CNTRL=0x20; DATA=a[thou]; n=1; delay_ms(5); } }

To compile the above C code you need the CodeVision AVR software. The software has it’s own IDE and built-in AVR gcc- Compiler. They must be properly installed and a project with correct settings must be created in order to compile the code. To compile the above code, the C file must be added to the project.

In CodeVision AVR software, you can develop or debug the project without any hardware setup. You must compile the code for generating HEX file. In debugging Mode, you want to check the port output without microcontroller Board.

The AVR Code Blaster software is used to download the hex file into your microcontroller through Parallel port.

Testing the I2C – Seven segment with AVR

Give +12V power supply to AVR Development board the four seven segment display is connected with the AVR Development board. First check the entire seven segments LED’s are properly working or not. Here we are display just 1234 in four seven segment. The entire seven segments receive it through Port lines & display it in order.

If any data is not coming in seven segments, then you just check the entire seven segments LED’s are working or not. Change the seven segment driver IC & Check the I2C connections. Check the four seven segments connections. Otherwise you just check the code with debugging mode in CodeVisionAVR.

General Information

  • For proper working use the components of exact values as shown in Circuit file. Wherever possible use new components.
  • Solder everything in a clean way. A major problem arises due to improper soldering, solder jumps and loose joints.
  • Use the exact value crystal shown in schematic.
  • More instructions are available in following articles,

    User Manual for ATMEGA Development Kit

    How to create & Debug a Project in CodeVision AVR