0% found this document useful (0 votes)
3 views2 pages

Mcsec 3

Uploaded by

nournashat07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Mcsec 3

Uploaded by

nournashat07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Seven Segment

A 7-segment display has 8 pins (7 segments + 1 for the decimal


point) for controlling the LED segments. The segments are
labeled as a, b, c, d, e, f, g, and dp (decimal point).

There are two types:

1. Common Anode (CA): All LEDs share a common


positive terminal.
o To turn a segment ON, send LOW (0).
2. Common Cathode (CC): All LEDs share a common
negative terminal.
o To turn a segment ON, send HIGH (1).

Connection of 7-Segment Display to ATmega32


Steps to connect:

1. Connect 7 pins of the display (a, b, c, d, e, f, g) to PORTA pins (PA0 to PA6).


2. Connect the common cathode pin to GND.
3. Connect the decimal point (dp) to PA7 (optional).
4. Use current-limiting resistors (220Ω) in series with each segment to protect the LEDs.
Code for Displaying Digits 0-9
#include <asf.h>
#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>

int main (void)


{
DDRC=0XFF;
while(1)
{
PORTC=0b00111111;
_delay_ms(1000);

PORTC=0b00000110;
_delay_ms(1000);

PORTC=0b01011011;
_delay_ms(1000);

PORTC=0b01001111;
_delay_ms(1000);

PORTC=0b01100110;
_delay_ms(1000);

PORTC=0b01101101;
_delay_ms(1000);

PORTC=0b11111101;
_delay_ms(1000);

PORTC=0b00000111;
_delay_ms(1000);

PORTC=0B01111111;
_delay_ms(1000);

PORTC=0b11101111;
_delay_ms(1000);
}

You might also like