Fa20-Bee-150 MP Lab Report - 03
Fa20-Bee-150 MP Lab Report - 03
Microprocessors
Eee-342
CLASS: BEE-5c
REG No: FA20-BEE-150
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;
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:
Look up Table:
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;
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
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;
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
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.