0% found this document useful (0 votes)
24 views7 pages

Fa20-Bee-150 MP Lab Report - 03

1. This lab report describes interfacing a 7-segment display with an AVR microcontroller. Code was written to toggle the display and increment a counter from 0-9. 2. Software and hardware simulations were performed to display numbers on a 7-segment display by connecting it to an Arduino Nano. 3. For the post-lab task, two 7-segment displays were connected and code was written to count from 0-99 on the displays.

Uploaded by

Saadat Khan
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)
24 views7 pages

Fa20-Bee-150 MP Lab Report - 03

1. This lab report describes interfacing a 7-segment display with an AVR microcontroller. Code was written to toggle the display and increment a counter from 0-9. 2. Software and hardware simulations were performed to display numbers on a 7-segment display by connecting it to an Arduino Nano. 3. For the post-lab task, two 7-segment displays were connected and code was written to count from 0-99 on the displays.

Uploaded by

Saadat Khan
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/ 7

1 Lab Report - 03

Microprocessors
Eee-342

LAB#03 “Interfacing 7-segment display using I/O


ports”

NAME: Muhammad Umar

CLASS: BEE-5c
REG No: FA20-BEE-150

INSTRUCTOR: Sir Raheel Ahmed


2 Lab Report - 03

Pre Lab-Tasks:
A seven-segment display relates to Port D. Write a code to toggle all the segments
simultaneously with some delay.

Code:
#include <avr/io.h>
# define F_CPU 16000000UL
#include <util/delay.h>

int main(void)
{
/* Replace with your application code */

DDRB = 0xFF;
DDRD = 0xFF;

unsigned char seven_seg_array[10] =


{0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
unsigned char counter = 0;

while (1)
{
PORTB = counter;
PORTD = seven_seg_array[counter];
_delay_ms(500);
counter++;

if(counter==10){
counter = 0;
}
}

return 0;
}

Proteus Simulation:
3 Lab Report - 03

In Lab Tasks:

Interfacing seven segment Display width AVR microcontroller:

Look up Table:

Seven Segment Pins

Digit to be Hexadecimal
displayed h g f e d c b a Value

AVR pins

0 0 0 1 1 1 1 1 1 0X3F

1 0 0 0 0 0 1 1 0 0X06

2 0 1 0 1 1 0 1 1 0x5B

3 0 1 0 0 1 1 1 1 0X4F

4 0 1 1 0 0 1 1 0 0X66

5 0 1 1 0 1 1 0 1 0X6D

6 0 1 1 1 1 1 0 1 0X7D

7 0 0 0 0 0 1 1 1 0X07

8 0 1 1 1 1 1 1 1 0X7F

9 0 1 1 0 1 1 1 1 0X6F
4 Lab Report - 03

Software Simulation:

Code:

#include <avr/io.h>
# define F_CPU 16000000UL
#include <util/delay.h>

int main(void)
{
/* Replace with your application code */

DDRB = 0xFF;
DDRD = 0xFF;

unsigned char seven_seg_array[10] =


{0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
unsigned char counter = 0;

while (1)
{
PORTB = counter;
PORTD = seven_seg_array[counter];
_delay_ms(500);
counter++;

if(counter==10){
counter = 0;
}
}

return 0;
}

Proteus Simulation:
5 Lab Report - 03

Hardware Implementation using Arduino nano:

Post Lab Task:

Connect 2 seven segments with Atmega 328P (As shown in schematic below).
Write a code to count from 0-99 on these 7- segments.

Code:

#include <avr/io.h>
# define F_CPU 16000000UL
#include <util/delay.h>

int main(void)
{
/* Replace with your application code */

DDRB = 0xFF;
6 Lab Report - 03

DDRD = 0xFF;

unsigned char seven_seg_array[10] =


{0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
unsigned char counter1 = 0;
unsigned char counter2 = 0;

while (1)
{
PORTB = counter1;
PORTD = seven_seg_array[counter2];
_delay_ms(1000);
counter2++;

if(counter2==10){
counter2 = 0;
counter1++;

}
if(counter1==10){
counter1=0;
counter2=0;
}
}

return 0;
}

Proteus Simulation:
7 Lab Report - 03

Critical Analysis / Conclusion:

In this lab I learned about interfacing seven segment display with ATmega328P controller.
Learned about the structure of seven segment display and its types of common anode
and common cathode. Learned about methods to check the type of the seven-segment
using digital multimeter. Performed a task in which I have to display numbers from 0-9
using seven segment display on proteus as well as hardware. Also used 7 segment BCD
display on proteus. In post Lab wrote a code which displays numbers from 0-99 using two
seven segments on proteus.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy