Led 7 Seg Keypad
Led 7 Seg Keypad
BECE204L
Microprocessors and Microcontrollers
Module 5
I/O interfacing with Microcontroller 8051
Module:5
I/O interfacing with Microcontroller 8051
LCD, LED, Keypad, Analog-to-Digital Convertors, Digital-to-
Analog Convertors, Sensor with Signal Conditioning Interface.
7 hours
1
26-03-2024
LED
2
26-03-2024
LED
• When the anode of an LED is made positive with respect
to the cathode, it will be forward-biased (ON) and will
emit the light.
LED
• The pin P1.0 is connected to a buffer (inverter).
• When P1.0 is high, output of an inverter is low causing the
current to flow through the LED and it will glow.
• When P1.0 is low, output of an inverter is high, and no
current flows through the LED and will stop emitting light.
• The inverter in the circuit acts as a current buffer and
prevents the port pins from current loading, the current
flows between the inverter and the 5 V supply.
• The resistor R limits the current through the LED and
protects it from damage.
3
26-03-2024
4
26-03-2024
Problems
• Write a ALP to blink LED connected on Port 2
5
26-03-2024
Problems
Problems
• Write an ALP to blink one led connected on P1.0
6
26-03-2024
Problems
Problems
• Interface eight LEDs and eight pushbutton switches to Port 3 and Port 2 of
89C51 respectively. Write a program to monitor the status of all switches
and display it on the corresponding LEDs, i.e. LED 0 should glow when switch
0 is pressed and so on.
7
26-03-2024
Problems
• Write a ALP to read the status of a switch connected on P0.0 and turn the led
connected on P2.0 on/off as per switch position
Problems
8
26-03-2024
Problems
• write a program to glow LEDS one by one in a sequence continuously.
9
26-03-2024
10
26-03-2024
11
26-03-2024
12
26-03-2024
To display 2021
13
26-03-2024
Types of LCD
• Depending on No. of characters and No. of Rows.
1×16 2×16
4×16 4×20
Pin Details
14
26-03-2024
15
26-03-2024
Initialization Comments
16
26-03-2024
Problem
17
26-03-2024
Problem
Problems
Write a ALP to display Hello VITV on port 2.
509 V
508 T
507 I
506 V
505
504 O
503 L
502 L
501 E
500 H
18
26-03-2024
Keyboard
• Keyboard – array of switches
• Types
– Mechanical
– Membrane
– Capacitors
– Hall-effect
• Mechanical switches are popular.
• Contact bounce problem- switch contacts do not come to rest
immediately.
• Human cannot type more than 50 keys per second
Keyboard
19
26-03-2024
Keyboard
Keyboard
20
26-03-2024
Keyboard
• Row – output, Column - Input
21
26-03-2024
Keypad Interfacing
• Port 1 –output -00H (0000 0000)
• Port 2- input – 0FH (0000 1111)
• Key pressed, which key, KEY to seven segment
0 0
1 1
7 segment display
22
26-03-2024
Problems
Problems
23
26-03-2024
Switch Bouncing
24
26-03-2024
De-bouncing Solutions
• Hardware debouncing
• Software debouncing
• RC debouncing
• Using debouncing IC’s
Hardware debouncing
• Hardware debouncing uses an SR latch to avoid bounces in the
circuit along with the pull up resistors
SW B A Q
OFF 1 0 0
ON 0 1 1
25
26-03-2024
RC debouncing
• Uses capacitor to filter out quick changes in the switch signal
SW B out
OFF 1 0
ON 0 1
Debouncing IC’s
• MAX6816, MAX6817, MAX6818, MC 14490, LogiSwitch LS118
26
26-03-2024
Software debouncing
• Adding delay force the controller to stop for a particular time
period
• Using delay, not a good solution, it pauses the program and
increase the processing time
• Use interrupt
27