Académique Documents
Professionnel Documents
Culture Documents
Objectives:
Learn to interface components like seven-segment display using digital I/O ports.
Required Tools:
Software Tools:
AVR Studio/ Atmel Studio
Proteus ISIS
AVRDUDESS
Hardware Tools:
Arduino Nano - 1
7-Segment Display - 1
Resistors 470 Ω 8
LED - 1
Wires - -
Pre-Lab
Every LED is assigned a name from 'a' to 'h' and is identified by its name. Seven LEDs 'a' to 'g'
are used to display the numerals while eighth LED 'h' is used to display the dot/decimal.
Seven-segment displays are commonly used in digital clocks, clock radios, timers, wristwatches,
and calculators. They can also be found in motor-vehicle odometers, speedometers, radio
Lab # 03 Interfacing 7-Segment Display Using Digital I/O Ports
frequency indicators, and practically any other display that makes use
of alphanumeric characters alone.
In Common Cathode configuration, the negative terminals of all LEDs are connected to the
common pin. The common is connected to ground and a particular LED glows when its
corresponding pin is given high.
In Common anode arrangement, the positive terminals of all LEDs are connected to common
pin .The common pin is given a high logic and the LED pins are given low logic to display a
number.
Lab # 03 Interfacing 7-Segment Display Using Digital I/O Ports
The figure below shows Pin diagram of a 7- segment display. For common anode, COM pins
are given Vcc and for common cathode, COM pins are given ground.
Pre-Lab Task:
A seven segment display is connected with Port D. Write a code to toggle all the segments
simultaneously with some delay.
The pins PD0 and PD1 are connected to the receiver and transmitter of of USART respectively.
To use these pins for digital I/O, we have to disable the transmitter and receiver. This can be
done by disabling TXEN0 and RXEN0 bits in UCSR0B register.
UCSR0B&=~(1<<RXEN0);
In Lab:
Task 1:
a. Implement Pre-lab task on hardware to test all segments of a 7-Segment display.
b. Use DMM to test the 7-segment display and identify whether it is common cathode or
common anode (Lab instructor should explain the method of testing a 7-segment with
DMM).
Task 2:
0 0 0 1 1 1 1 1 1 0x3F
generating delays*/
int main(void)
I/O*/
unsigned char
seven_seg_array[10]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
_delay_ms(500);
if(counter==10)
counter=0;
return 0;
}
Lab # 03 Interfacing 7-Segment Display Using Digital I/O Ports
Task 1c-Simulation:
Download the hex file of your project in Atmega328P microcontroller using AVRDUDESS and
implement this task on hardware.
Lab # 03 Interfacing 7-Segment Display Using Digital I/O Ports
In Lab Task 2:
(To be specified by lab instructor)
Switches are connected to Port B for input and a seven segment display is connected to PORT
D of ATmega328p for output. Using these, perform a task assigned by your lab instructor.
Code:
Lab # 03 Interfacing 7-Segment Display Using Digital I/O Ports
Lab Assessment
Pre Lab /1
In Lab /5
Data
Post Lab /4 /4
Presentation
Writing Style /4