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

CMPE 30184 Lab Exercise No. 4 Switches and 7 Segment Displays 1 1

This document outlines a laboratory exercise for a Microprocessors course at the Polytechnic University of the Philippines, focusing on switches and 7-segment displays. It includes objectives, materials needed, and detailed instructions for programming various applications using an Arduino UNO, such as counters and a traffic light simulation. Additionally, it requires students to create video demonstrations of their projects and answer related questions.
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)
15 views7 pages

CMPE 30184 Lab Exercise No. 4 Switches and 7 Segment Displays 1 1

This document outlines a laboratory exercise for a Microprocessors course at the Polytechnic University of the Philippines, focusing on switches and 7-segment displays. It includes objectives, materials needed, and detailed instructions for programming various applications using an Arduino UNO, such as counters and a traffic light simulation. Additionally, it requires students to create video demonstrations of their projects and answer related questions.
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

Republic of the Philippines

POLYTECHNIC UNIVERSITY OF THE PHILIPPINES


COLLEGE OF ENGINEERING
COMPUTER ENGINEERING DEPARTMENT

CMPE 30184
Microprocessors

LAB EXERCISE

4
SWITCHES and 7-SEGMENT DISPLAYS
Group #N (your group number)
(list all team members and affix signatures)
Team Members Signature

Demonstration of Programs

Program Successfully
Demonstrated
1
2
3
4
5
6
LAB 4: Switches and 7-segment Displays
Duration: 3 Hours
A. Objectives
The objectives of this laboratory are to introduce the student to:
• Current-limiting resistors and pull-down resistors
• Switch debouncing
• Active-LOW versus active-HIGH outputs
• 7-segment displays (common anode and common cathode)
• Writing Arduino programs to read pushbutton switches and control 7-segment displays

B. Materials
Breadboard with Arduino UNO
Adaptor (120V AC to 12 VDC, 1000 mA)
Seven 220 " resistors
10 k" resistor
Common-anode 7-segment display (GNS 3011 or similar)
Momentary pushbutton switch (BTS-1102B-2 or similar)

C. Introduction
Circuit 1 below will be constructed and tested in lab using programs written for the Arduino
UNO.

Circuit 1
Write a C++ program (Program 1) for the Arduino UNO as described below. Be sure to include an
initial block of comments at the start of each program as well as comments throughout. Compile
each program before lab and correct any errors that occur.

• The count should be initialized to 0 and shown on the 7-segment display and the
computer screen.
• When the user presses the button, the count should advance, and the new value
should be displayed on the 7-segment display and the computer screen.
• The count should be mod-10 (0 to 9 and repeat).
• Use the displaydigit( ) function described presentation for this lab.
• Use the readButton( ) function provided in the presentation for this lab to allow for
switch debounce.
• See below for more details on the code.

// Global variables for readButton( ) function


// Other global variables
void setup( )
{ // Define input and output pins
// Set up serial communication
// Display instructions on the computer screen
// Display initial value (0) on 7-segment display
// Display initial value (0) on computer screen
}
void loop( )
{ // If button is pressed:
// Increment counter
// Adjust counter for mod-10 operation
// Display count on computer screen
// Display count on 7-segment display
}
void readButton(int buttonPin)
{

}
void display_digit(int N)
{
/
}
TAKE CHALLENGE:

Create a video presentation of all the solved problems. Upload that video on your newly
created YOUTUBE channel and create and paste here the QR code for validation and
checking. Provided QR Code to view the video: (See sample QR Code)

1. Program 2 – Switch-Controlled UP/DOWN COUNTER


•Connect a toggle switch and a 7-segment display on the Arduino Uno Board.
•Write a program to control an UP/DOWN Counter using a toggle switch, that is,
when SW = ON (the counter counts Upward 0 -> 9). Otherwise, it should count
downward (9 ->0)
•Provide a 0.75 second delay for every count interval.
•Run the program and verify that it works properly.
•Demonstrate proper operation of the program to the instructor.
•Save and print the program.
•Create a video demonstration of this program and save it to your YOUTUBE
channel. Then on your documentation provide the URL link of this video with
matching QR code for easy viewing
• Cut and paste a screen snapshot picture of the final running circuit as your
experiment output.

2) Program 3 – Presettable UP/DOWN Counter


• Connect a toggle switch, 3 switches DIP Switch and a 7-segment display on the
Arduino Uno Board
•Write a program to ask the user to enter a predefined number to start the count
from and a toggle switch input to determine whether to count Up or Down
•The program can be switched from UP or DOWN interactively by switching the
toggle switch
•Provide a 0.75 second delay per count transition.
•Run the program and verify that it works properly.
•Demonstrate proper operation of the program to the instructor.
•Create a video demonstration of this program and save it to your YOUTUBE
channel. Then on your documentation provide the URL link of this video with
matching QR code for easy viewing
•Cut and paste a screen snapshot picture of the final running circuit as your
experiment output.
•Save and print the program.

3) Program 4 – Traffic Light Circuit with Seven-segment Down Counter


•Connect three LEDs (Green, Yellow, and Red) and three 220 " resistors to the
digital output pins of your choice.
•Write a program to simulate a traffic light where the Green LED is on for 9
seconds, Yellow if on for 1 second, and Red is on for 8 seconds. Provide
synchronized timing to the DOWN COUNTER. The traffic light should operate
forever.
•Run the program and verify that it works properly.
•Demonstrate proper operation of the program to the instructor.
• Create a video demonstration of this program and save it to your YOUTUBE
channel. Then on your documentation provide the URL link of this video with
matching QR code for easy viewing
•Cut and paste a screen snapshot picture of the final running circuit as your
experiment output.
•Save and print the program.

4) Program 5 – Design your own switch and Seven-segment Application.


• Construct the test circuit on your Arduino Uno Board
• Run the program and verify that it works properly.
• Demonstrate proper operation of the program to the instructor.
•Create a video demonstration of this program and save it to your YOUTUBE
channel. Then on your documentation provide the URL link of this video with
matching QR code for easy viewing
• Cut and paste a screen snapshot picture of the final running circuit as your
experiment output.
• Save and print the program

5) Program 6 – 7-Segment Display MARQUEE Effect


• Construct the test circuit on your Arduino Uno Board which comprises of the
following components: 2 pieces LDR (Light Dependent Resistor), 2 pieces of 7-
segment display or Dual Display whichever is available.
• Create a program that will be display a MARQUEE effect of 2 Messages:
If LDR1 was enabled, it should display the message HELLO from LEFT to RIGHT
direction. Otherwise, display the message BYE from RIGHT to LEFT direction.
• Run the program and verify that it works properly.
• Demonstrate proper operation of the program to the instructor.
• Create a video demonstration of this program and save it to your YOUTUBE
channel. Then on your documentation provide the URL link of this video with
matching QR code for easy viewing
• Cut and paste a screen snapshot picture of the final running circuit as your
experiment output.
• Save and print the program.

QUESTIONS TO ANSWER:

1. How to interface a 7-segment to an ARDUINO UNO Board?


_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________

2. What is the difference between a COMMON CATHODE 7-Segment Display from a


COMMON ANODE 7-segment Display?
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________

3. Discuss the principle of multiplexing the 7-Segment Display.


______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________

4.How to interface a Light-dependent Resistor (LDR) to an ARDUINO UNO Board?


______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
REFLECTIONS:
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________

REFERENCES:
http://arduino.cc/en/
http://en.wikipedia.org/wiki/Arduino
http://www.arduino.cc/en/Guide/Environment
http://arduino.cc/en/Tutorial/Sketch

You might also like