0% found this document useful (0 votes)
90 views3 pages

EE540 Lab Experiment 5

This document describes an experiment to interface a pushbutton, LED, and 7-segment LED display with an Atmega328P microcontroller. The objectives are to write assembly and C programs to control these devices. Two circuits are described - one with a pushbutton and LED, and one with a pushbutton and 7-segment display. The document outlines programs to toggle an LED based on button state, delay an LED for 1 minute, count button presses on a display, and simulate a dice roll by displaying random numbers on the 7-segment display when the button is pressed. Materials required and procedures for building the circuits and programming the microcontroller are provided.

Uploaded by

VIGHNESH AIYA
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)
90 views3 pages

EE540 Lab Experiment 5

This document describes an experiment to interface a pushbutton, LED, and 7-segment LED display with an Atmega328P microcontroller. The objectives are to write assembly and C programs to control these devices. Two circuits are described - one with a pushbutton and LED, and one with a pushbutton and 7-segment display. The document outlines programs to toggle an LED based on button state, delay an LED for 1 minute, count button presses on a display, and simulate a dice roll by displaying random numbers on the 7-segment display when the button is pressed. Materials required and procedures for building the circuits and programming the microcontroller are provided.

Uploaded by

VIGHNESH AIYA
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/ 3

Experiment​ ​5

Interfacing​ ​Pushbutton,​ ​LED,​ ​and


Seven​ ​Segment​ ​LED​ ​Display​ ​with
Atmega328P​ ​MCU
Objectives
● To​ ​interface​ ​a​ ​pushbutton​ ​and​ ​an​ ​LED​ ​with​ ​Atmega328P​ ​MCU​ ​and​ ​execute​ ​some
assembly​ ​language​ ​and/or​ ​C​ ​programs​ ​to​ ​use​ ​these​ ​devices.
● To​ ​interface​ ​a​ ​pushbutton​ ​and​ ​a​ ​seven​ ​segment​ ​LED​ ​display​ ​with​ ​Atmega328​ ​MCU
and​ ​execute​ ​some​ ​assembly​ ​language​ ​and/or​ ​C​ ​programs​ ​to​ ​use​ ​these​ ​devices.

Mapped​ ​Course​ ​Outcomes


CO-3 Develop​ ​assembly​ ​language​ ​programs​ ​for​ ​the​ ​selected​ ​MCU​ ​using​ ​available​ ​tools.
CO-4 Develop​ C ​ /C++​ ​language​ ​programs​ ​for​ ​the​ ​selected​ ​MCU​ ​using​ ​available​ ​tools.
CO-5 Interface​ A​ tmega328P​ ​MCU​ ​to​ ​a​ ​variety​ ​of​ ​analog​ ​and​ ​digital​ ​input​ ​and​ ​output
devices​ ​to​ ​perform​ ​meaningful​ ​tasks.

Introduction
In this experiment we have to interface a pushbutton and an LED to Atmega328P as shown
in Figure 1 and interface a pushbutton and a common cathode LED display as shown in
Figure 2. We should note that whenever a pushbutton is interfaced to the Atmega328P
MCU, the internal pull-up resistor in the MCU should be enabled for that input line by
appropriate​ ​instruction​ ​sequence​ ​in​ ​the​ ​program.

Figure​ ​1:​ ​Interfacing​ ​pushbutton​ ​and​ ​an​ ​LED.


JSS​ ​S&TU,​ ​SJCE,​ ​Dept.​ ​of​ ​E&EE,​ ​V​ ​Semester​ ​B.E.​ ​in​ ​E&EE

Figure​ ​2​ ​:​ ​Interfacing​ ​a​ ​pushbutton​ ​and​ ​a​ ​7-segment​ ​LED​ ​display.

Using the hardware shown in Figure 1, it is required to perform the following tasks by writing
appropriate​ ​programs​ ​in​ ​both​ ​assembly​ ​language​ ​and​ ​in​ ​C:

1. Write a program to monitor the status of the pushbutton in Figure 1. As long as the
pushbutton is not pressed, the LED should be OFF. As long as the pushbutton is
pressed​ ​the​ ​LED​ ​should​ ​be​ ​turned​ ​ON.
2. For the hardware shown in Figure 1, write a program to monitor the status of
pushbutton. As long as the pushbutton is not pressed, the LED should be OFF. Once
the pushbutton is pressed, the LED should glow for one minute and then turn OFF.
Realize​ ​time​ ​delay​ ​by​ ​software.​ ​Check​ ​the​ ​timing​ ​using​ ​a​ ​stopwatch.

To understand how to develop programs in C for Atmega328P refer to the slides given in the
theory class. On the hardware shown in Figure 2, we have to perform the following tasks by
writing​ ​appropriate​ ​programs​ ​in​ ​both​ ​assembly​ ​language​ ​and​ ​in​ ​C:

1. For the hardware shown in Figure 2, write a assembly language program and also a
C program to count the number of times the pushbutton is pressed and display it on
the seven segment display. For eg., initially the display should be 0. Whenever
pushbutton is pressed and released, the display should increment by 1. After 9, the
counting​ ​should​ ​reset​ ​to​ ​0​ ​and​ ​repeat.
2. In Figure 2, let a high-to-low logic change on INT0/PD2 pin cause an INT0 interrupt.
Write an assembly language program and also a C program to display on the LED
display any integer in the range 1 to 6, both inclusive, whenever the pushbutton is
pressed, thus simulating throwing of a dice. Sketch a flowchart to show the logic.
Note​ ​that​ ​here​ ​we​ ​have​ ​enable​ ​INT0​ ​interrupt.

Materials​ ​Required
● The​ ​latest​ ​version​ ​of​ ​Atmel​ ​Studio​ ​installed​ ​on​ ​a​ ​computer.
● Atmel-ICE​ ​Basic​ ​Programmer.
● Common​ ​Cathode​ ​Type​ ​7-segment​ ​LED​ ​Display​ ​--​ ​1​ ​No.
● 220​ ​Ω,​ ​0.25​ ​W​ ​resistor​ ​--​ ​9​ ​Nos.
● 3​ ​mm​ ​LED​ ​--​ ​1​ ​No.
● Pushbutton​ ​which​ ​can​ ​be​ ​mounted​ ​on​ ​a​ ​breadboard​ ​--​ ​1​ ​No.
● Atmega328P​ ​MCU​ ​--​ ​1​ ​No.
● Breadboard​ ​with​ ​regulated​ ​power​ ​supply​ ​built​ ​in​ ​Experiment​ ​1​ ​and​ ​patch​ ​cords.

EE540​ ​Microcontroller​ ​Lab​ ​Experiment​ ​5 3​ ​of​ ​3


JSS​ ​S&TU,​ ​SJCE,​ ​Dept.​ ​of​ ​E&EE,​ ​V​ ​Semester​ ​B.E.​ ​in​ ​E&EE

Procedure
First the hardware is built as per Figures 1 and 2. After this, the projects are created in Atmel
Studio as explained in earlier experiments. While creating C programs, C/C++ is selected as
project type in Atmel Studio. Rest of the procedure for building the project is same as
explained​ ​in​ ​earlier​ ​experiments.

After the project is built, the MCU is programmed by following the same procedure explained
in​ ​Experiment​ ​4.

Program​ ​is​ ​verified​ ​by​ ​checking​ ​the​ ​output​ ​after​ ​operating​ ​the​ ​pushbutton.

Conclusion
Pushbutton, LED and seven segment LED display have been interfaced to Atmega328P
MCU. Programs have been written to perform the specified tasks on the hardware and
verified.

EE540​ ​Microcontroller​ ​Lab​ ​Experiment​ ​5 3​ ​of​ ​3

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