尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
Switches and LEDs Interface to the 8051
Microcontroller
Prepared by:
Afrah Salman
Switch Basics
• A switch is an electrical component that can break an electrical
circuit, interrupting the current or diverting it from one
conductor to another.
• If we directly connect a switch to one of the microcontroller port
pins, the pin floats when the switch is open. Meaning, it is not at
a fixed logic level 0v or 5v.
PinAssignment with 8051
Interfacing Switch
• Fig. 1 shows how to interface the switch to microcontroller. A simple
switch has an open state and closed state. However, a
microcontroller needs to see a definite high or low voltage level at a
digital input. A switch requires a pull-up or pull-down resistor to
produce a definite high or low voltage when it is open or closed. A
resistor placed between a digital input and the supply voltage is
called a "pull-up" resistor because it normally pulls the pin's voltage
up to the supply.
Fig.1InterfacingswitchtoMicrocontroller
LED Basics
• Light Emitting Diodes are the semi conductor light sources.
Commonly used LEDs will have a cut-off voltage of 1.7V and
current of 10mA. When an LED is applied with its required
voltage and current it glows with full intensity. The Light
Emitting Diode is similar to the normal PN diode but it emits
energy in the form of light. The color of light depends on the
band gap of the semiconductor.
Interface to the Microcontroller
• Now we could go ahead and interface it to the
microcontroller, but we would rather interface 8 switches
and 8 LED's to two ports as shown in the schematic below.
• As we can see the schematic has basic circuits for
oscillator, reset and power connections for the
microcontroller.
• A DIP (dual in line package) Switch, array of 8
switches is connected to PORT3 AND 8 LEDs
toPORT2.
• Observe the RR1 component, it is array of 8 resistors
in a single pack(SIP). It is as good as connecting 8
pull-up resistors as shown in figure 1. You could also
use 8 discrete resistors as well.
Interfacing Switch with 8051
• We now want to control the LED by using switches in 8051 Slicker
Board. It works by turning ON a LED & then turning it OFF when
switch is going to LOW or HIGH. The 8051 Slicker board has eight
numbers of point LEDs, connected with I/O Port lines (P0.0 – P0.7)
to make port pins high. Eight switches, connected with I/O port
lines (P2.0 – P2.7) are used to control eight LEDs.
Circuit Diagram to Interface Switch with 8051
Example1:The following program will make the value of PIN3.1 keeps
toggling (ON/OFF) after some delay.
org 00H
;MAIN PROGRAM
Toggle: MOV P3, #01H ;move 00000001 to PORT3
CALL delay ;execute delay
MOV A, P3 ;move PORT3 value to
accumulator
CPL A ;complement PORT3 value
MOV P3, A ;move 11111110 to PORT3
CALL delay ;execute delay
SJMP Toggle
;DELAY SUB-ROUTINE
delay: MOV R5, #10 ;load register R5 with 10
third: MOV R6, #200 ;load register R6 with 200
second: MOV R7, #200 ;load register R7 with 200
DJNZ R7, $ ;decrement R7 till it is zero
DJNZ R6, second ;decrement R6 till it is zero
DJNZ R5, third ;decrement R5 till it is zero
ret ;go back to main program
END
Example2:Aswitch is connected to pin PI .7. Write a program to check the
status of SW and perform the following:
If SW=0, send letter ‘N’ to P2., If SW=1, send letter ‘Y’ to P2.
org 00H
;MAIN PROGRAM
SETB P1.7 ;make P1.7 an input
AGAIN: JB P1.2, OVER ;jump if P1.7=1
MOV P2, #’N’ ;SW=0, issue ‘N’ to P2
SJMP AGAIN ;keep monitoring
OVER: MOV P2,#’Y’ ;SW=1, issue ‘Y’ to P2
SJMP AGAIN ;keep monitoring
Example3:Aswitch is connected to pin PI .7 and an LED to pin P2.7. Write
a program to get the status of the switch and send it to the LED.
org 00H
;MAIN PROGRAM
SETB P1.7 ;make P1.7 an input
AGAIN: MOV C,P1.0 ;read the SW status into CF
MOV P2.7, C ;send the SW status to LED
SJMP AGAIN ;keep repeating
Note: The instruction “MOV P2.7, P1.0” is wrong since such an
instruction doesn’t exist. However, “MOV P2, P1” is a valid instruction.

More Related Content

What's hot

8051 timer counter
8051 timer counter8051 timer counter
8051 timer counter
vishalgohel12195
 
8051 data types and directives
8051 data types and directives8051 data types and directives
8051 data types and directives
SARITHA REDDY
 
INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER
 INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER   INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER
INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER
SIRILsam
 
Microcontroller 8051 and its interfacing
Microcontroller 8051 and its interfacingMicrocontroller 8051 and its interfacing
Microcontroller 8051 and its interfacing
Ankur Mahajan
 
8051 microcontroller features
8051 microcontroller features8051 microcontroller features
8051 microcontroller features
Tech_MX
 
Keypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 MicrocontrollerKeypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 Microcontroller
Sudhanshu Janwadkar
 
8051 programming in c
8051 programming in c8051 programming in c
8051 programming in c
Dr. Ritula Thakur
 
8086 micro processor
8086 micro processor8086 micro processor
8086 micro processor
Poojith Chowdhary
 
Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...
NimeshSingh27
 
Interfacing LCD with 8051 Microcontroller
Interfacing LCD with 8051 MicrocontrollerInterfacing LCD with 8051 Microcontroller
Interfacing LCD with 8051 Microcontroller
Pantech ProLabs India Pvt Ltd
 
I o ports and timers of 8051
I o ports and timers of 8051I o ports and timers of 8051
I o ports and timers of 8051
SARITHA REDDY
 
Intel 8051 Programming in C
Intel 8051 Programming in CIntel 8051 Programming in C
Intel 8051 Programming in C
Sudhanshu Janwadkar
 
Sensor interfacing in 8051
Sensor interfacing in 8051Sensor interfacing in 8051
Sensor interfacing in 8051
Irfan Ahmad
 
8051 Addressing Modes
8051 Addressing Modes8051 Addressing Modes
8051 Addressing Modes
Senthil Kumar
 
UART
UARTUART
Addressing modes of 8051
Addressing modes of 8051Addressing modes of 8051
Addressing modes of 8051
SARITHA REDDY
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architecture
DominicHendry
 
Interfacing adc
Interfacing adcInterfacing adc
Interfacing adc
PRADEEP
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction set
Andri Prastiyo
 
Seven segment interfacing with 8051.pdf
Seven segment interfacing with 8051.pdfSeven segment interfacing with 8051.pdf
Seven segment interfacing with 8051.pdf
Srikrishna Thota
 

What's hot (20)

8051 timer counter
8051 timer counter8051 timer counter
8051 timer counter
 
8051 data types and directives
8051 data types and directives8051 data types and directives
8051 data types and directives
 
INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER
 INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER   INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER
INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER
 
Microcontroller 8051 and its interfacing
Microcontroller 8051 and its interfacingMicrocontroller 8051 and its interfacing
Microcontroller 8051 and its interfacing
 
8051 microcontroller features
8051 microcontroller features8051 microcontroller features
8051 microcontroller features
 
Keypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 MicrocontrollerKeypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 Microcontroller
 
8051 programming in c
8051 programming in c8051 programming in c
8051 programming in c
 
8086 micro processor
8086 micro processor8086 micro processor
8086 micro processor
 
Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...
 
Interfacing LCD with 8051 Microcontroller
Interfacing LCD with 8051 MicrocontrollerInterfacing LCD with 8051 Microcontroller
Interfacing LCD with 8051 Microcontroller
 
I o ports and timers of 8051
I o ports and timers of 8051I o ports and timers of 8051
I o ports and timers of 8051
 
Intel 8051 Programming in C
Intel 8051 Programming in CIntel 8051 Programming in C
Intel 8051 Programming in C
 
Sensor interfacing in 8051
Sensor interfacing in 8051Sensor interfacing in 8051
Sensor interfacing in 8051
 
8051 Addressing Modes
8051 Addressing Modes8051 Addressing Modes
8051 Addressing Modes
 
UART
UARTUART
UART
 
Addressing modes of 8051
Addressing modes of 8051Addressing modes of 8051
Addressing modes of 8051
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architecture
 
Interfacing adc
Interfacing adcInterfacing adc
Interfacing adc
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction set
 
Seven segment interfacing with 8051.pdf
Seven segment interfacing with 8051.pdfSeven segment interfacing with 8051.pdf
Seven segment interfacing with 8051.pdf
 

Similar to Switches and LEDs interface to the 8051 microcontroller

Unit iv microcontrollers final
Unit iv microcontrollers finalUnit iv microcontrollers final
Unit iv microcontrollers final
SARITHA REDDY
 
Simple Automatic Water Level Controller
Simple Automatic Water Level ControllerSimple Automatic Water Level Controller
Simple Automatic Water Level Controller
selvalakshmi24
 
Ppt on interfacing led and 7 segment with 8951
Ppt on interfacing led and 7 segment with 8951 Ppt on interfacing led and 7 segment with 8951
Ppt on interfacing led and 7 segment with 8951
pooja jaiswal
 
Ppt on interfacing led and 7 segmentwith 8951
Ppt on interfacing led  and 7 segmentwith 8951Ppt on interfacing led  and 7 segmentwith 8951
Ppt on interfacing led and 7 segmentwith 8951
pooja jaiswal
 
project
projectproject
project
guest2f918d
 
ppt of automatic room light controller and BI directional counter
ppt of automatic room light controller and BI directional counterppt of automatic room light controller and BI directional counter
ppt of automatic room light controller and BI directional counter
Mannavapremkumar
 
Automatic street light controller
Automatic street light controllerAutomatic street light controller
Automatic street light controller
suresh shindhe
 
8051interfacing 190425062221
8051interfacing 1904250622218051interfacing 190425062221
8051interfacing 190425062221
Indranil Hatai
 
Microcontroller ppt
Microcontroller pptMicrocontroller ppt
Microcontroller ppt
prajjwalsharma37
 
Battery level Indicator Circuit
Battery level Indicator CircuitBattery level Indicator Circuit
Battery level Indicator Circuit
Uzair Ahmad
 
pe lab manual
pe lab manualpe lab manual
pe lab manual
saisureshnaidu
 
Electrónica: Probador de LOPT/FBT Flyback
Electrónica: Probador de LOPT/FBT FlybackElectrónica: Probador de LOPT/FBT Flyback
Electrónica: Probador de LOPT/FBT Flyback
SANTIAGO PABLO ALBERTO
 
Probador de-flybacks
Probador de-flybacksProbador de-flybacks
Microprocessor based Temperature Controller
Microprocessor based Temperature ControllerMicroprocessor based Temperature Controller
Microprocessor based Temperature Controller
Revanth Reddy
 
Relay driver basic
Relay driver basicRelay driver basic
Relay driver basic
Bien Morfe
 
Fed vonverter project design and progress report
Fed vonverter project design and progress reportFed vonverter project design and progress report
Fed vonverter project design and progress report
MehboobUET
 
Self Switching Power Supply
Self Switching Power SupplySelf Switching Power Supply
Self Switching Power Supply
Edgefxkits & Solutions
 
Advanced motion controls se25a40ac
Advanced motion controls se25a40acAdvanced motion controls se25a40ac
Advanced motion controls se25a40ac
Electromate
 
Advanced motion controls se25a40
Advanced motion controls se25a40Advanced motion controls se25a40
Advanced motion controls se25a40
Electromate
 
Ppt on interfacing led and 7 segmentwith 8951
Ppt on interfacing led  and 7 segmentwith 8951Ppt on interfacing led  and 7 segmentwith 8951
Ppt on interfacing led and 7 segmentwith 8951
pooja jaiswal
 

Similar to Switches and LEDs interface to the 8051 microcontroller (20)

Unit iv microcontrollers final
Unit iv microcontrollers finalUnit iv microcontrollers final
Unit iv microcontrollers final
 
Simple Automatic Water Level Controller
Simple Automatic Water Level ControllerSimple Automatic Water Level Controller
Simple Automatic Water Level Controller
 
Ppt on interfacing led and 7 segment with 8951
Ppt on interfacing led and 7 segment with 8951 Ppt on interfacing led and 7 segment with 8951
Ppt on interfacing led and 7 segment with 8951
 
Ppt on interfacing led and 7 segmentwith 8951
Ppt on interfacing led  and 7 segmentwith 8951Ppt on interfacing led  and 7 segmentwith 8951
Ppt on interfacing led and 7 segmentwith 8951
 
project
projectproject
project
 
ppt of automatic room light controller and BI directional counter
ppt of automatic room light controller and BI directional counterppt of automatic room light controller and BI directional counter
ppt of automatic room light controller and BI directional counter
 
Automatic street light controller
Automatic street light controllerAutomatic street light controller
Automatic street light controller
 
8051interfacing 190425062221
8051interfacing 1904250622218051interfacing 190425062221
8051interfacing 190425062221
 
Microcontroller ppt
Microcontroller pptMicrocontroller ppt
Microcontroller ppt
 
Battery level Indicator Circuit
Battery level Indicator CircuitBattery level Indicator Circuit
Battery level Indicator Circuit
 
pe lab manual
pe lab manualpe lab manual
pe lab manual
 
Electrónica: Probador de LOPT/FBT Flyback
Electrónica: Probador de LOPT/FBT FlybackElectrónica: Probador de LOPT/FBT Flyback
Electrónica: Probador de LOPT/FBT Flyback
 
Probador de-flybacks
Probador de-flybacksProbador de-flybacks
Probador de-flybacks
 
Microprocessor based Temperature Controller
Microprocessor based Temperature ControllerMicroprocessor based Temperature Controller
Microprocessor based Temperature Controller
 
Relay driver basic
Relay driver basicRelay driver basic
Relay driver basic
 
Fed vonverter project design and progress report
Fed vonverter project design and progress reportFed vonverter project design and progress report
Fed vonverter project design and progress report
 
Self Switching Power Supply
Self Switching Power SupplySelf Switching Power Supply
Self Switching Power Supply
 
Advanced motion controls se25a40ac
Advanced motion controls se25a40acAdvanced motion controls se25a40ac
Advanced motion controls se25a40ac
 
Advanced motion controls se25a40
Advanced motion controls se25a40Advanced motion controls se25a40
Advanced motion controls se25a40
 
Ppt on interfacing led and 7 segmentwith 8951
Ppt on interfacing led  and 7 segmentwith 8951Ppt on interfacing led  and 7 segmentwith 8951
Ppt on interfacing led and 7 segmentwith 8951
 

More from University of Technology - Iraq

www.pptx
www.pptxwww.pptx
Security problems.pptx
Security problems.pptxSecurity problems.pptx
Security problems.pptx
University of Technology - Iraq
 
Information System (IS) life cycle.pptx
Information System (IS) life cycle.pptxInformation System (IS) life cycle.pptx
Information System (IS) life cycle.pptx
University of Technology - Iraq
 
Performance Evaluation for Software Defined Networking (SDN) Based on Adaptiv...
Performance Evaluation for Software Defined Networking (SDN) Based on Adaptiv...Performance Evaluation for Software Defined Networking (SDN) Based on Adaptiv...
Performance Evaluation for Software Defined Networking (SDN) Based on Adaptiv...
University of Technology - Iraq
 
Ch12 microprocessor interrupts
Ch12 microprocessor interruptsCh12 microprocessor interrupts
Ch12 microprocessor interrupts
University of Technology - Iraq
 
Performance and traffic management for WSNs
Performance and traffic management for WSNsPerformance and traffic management for WSNs
Performance and traffic management for WSNs
University of Technology - Iraq
 
IP address and Domain name
IP address and Domain nameIP address and Domain name
IP address and Domain name
University of Technology - Iraq
 
Computer science mcq alle books4u
Computer science mcq   alle books4uComputer science mcq   alle books4u
Computer science mcq alle books4u
University of Technology - Iraq
 
VANET
VANETVANET
Parallel Algorithms: Sort & Merge, Image Processing, Fault Tolerance
Parallel Algorithms: Sort & Merge, Image Processing, Fault ToleranceParallel Algorithms: Sort & Merge, Image Processing, Fault Tolerance
Parallel Algorithms: Sort & Merge, Image Processing, Fault Tolerance
University of Technology - Iraq
 
Wavelet Transform and DSP Applications
Wavelet Transform and DSP ApplicationsWavelet Transform and DSP Applications
Wavelet Transform and DSP Applications
University of Technology - Iraq
 
FSK, PSK, QAM
FSK, PSK, QAMFSK, PSK, QAM
SCHEDULING DAGs WITHOUT CONSIDERING COMMUNICATION
SCHEDULING DAGs WITHOUT CONSIDERING COMMUNICATIONSCHEDULING DAGs WITHOUT CONSIDERING COMMUNICATION
SCHEDULING DAGs WITHOUT CONSIDERING COMMUNICATION
University of Technology - Iraq
 
DSB-SC Demodulation using matlab
DSB-SC Demodulation using matlabDSB-SC Demodulation using matlab
DSB-SC Demodulation using matlab
University of Technology - Iraq
 
Main memory-2 (ch8,os)
Main memory-2 (ch8,os)Main memory-2 (ch8,os)
Main memory-2 (ch8,os)
University of Technology - Iraq
 
CMOS
CMOSCMOS
Wap
WapWap
8086 microprocessor lab manual
8086 microprocessor lab manual8086 microprocessor lab manual
8086 microprocessor lab manual
University of Technology - Iraq
 
Cloud computing
Cloud computingCloud computing

More from University of Technology - Iraq (19)

www.pptx
www.pptxwww.pptx
www.pptx
 
Security problems.pptx
Security problems.pptxSecurity problems.pptx
Security problems.pptx
 
Information System (IS) life cycle.pptx
Information System (IS) life cycle.pptxInformation System (IS) life cycle.pptx
Information System (IS) life cycle.pptx
 
Performance Evaluation for Software Defined Networking (SDN) Based on Adaptiv...
Performance Evaluation for Software Defined Networking (SDN) Based on Adaptiv...Performance Evaluation for Software Defined Networking (SDN) Based on Adaptiv...
Performance Evaluation for Software Defined Networking (SDN) Based on Adaptiv...
 
Ch12 microprocessor interrupts
Ch12 microprocessor interruptsCh12 microprocessor interrupts
Ch12 microprocessor interrupts
 
Performance and traffic management for WSNs
Performance and traffic management for WSNsPerformance and traffic management for WSNs
Performance and traffic management for WSNs
 
IP address and Domain name
IP address and Domain nameIP address and Domain name
IP address and Domain name
 
Computer science mcq alle books4u
Computer science mcq   alle books4uComputer science mcq   alle books4u
Computer science mcq alle books4u
 
VANET
VANETVANET
VANET
 
Parallel Algorithms: Sort & Merge, Image Processing, Fault Tolerance
Parallel Algorithms: Sort & Merge, Image Processing, Fault ToleranceParallel Algorithms: Sort & Merge, Image Processing, Fault Tolerance
Parallel Algorithms: Sort & Merge, Image Processing, Fault Tolerance
 
Wavelet Transform and DSP Applications
Wavelet Transform and DSP ApplicationsWavelet Transform and DSP Applications
Wavelet Transform and DSP Applications
 
FSK, PSK, QAM
FSK, PSK, QAMFSK, PSK, QAM
FSK, PSK, QAM
 
SCHEDULING DAGs WITHOUT CONSIDERING COMMUNICATION
SCHEDULING DAGs WITHOUT CONSIDERING COMMUNICATIONSCHEDULING DAGs WITHOUT CONSIDERING COMMUNICATION
SCHEDULING DAGs WITHOUT CONSIDERING COMMUNICATION
 
DSB-SC Demodulation using matlab
DSB-SC Demodulation using matlabDSB-SC Demodulation using matlab
DSB-SC Demodulation using matlab
 
Main memory-2 (ch8,os)
Main memory-2 (ch8,os)Main memory-2 (ch8,os)
Main memory-2 (ch8,os)
 
CMOS
CMOSCMOS
CMOS
 
Wap
WapWap
Wap
 
8086 microprocessor lab manual
8086 microprocessor lab manual8086 microprocessor lab manual
8086 microprocessor lab manual
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 

Recently uploaded

78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
Kalna College
 
220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology
Kalna College
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapitolTechU
 
Brand Guideline of Bashundhara A4 Paper - 2024
Brand Guideline of Bashundhara A4 Paper - 2024Brand Guideline of Bashundhara A4 Paper - 2024
Brand Guideline of Bashundhara A4 Paper - 2024
khabri85
 
Observational Learning
Observational Learning Observational Learning
Observational Learning
sanamushtaq922
 
How to stay relevant as a cyber professional: Skills, trends and career paths...
How to stay relevant as a cyber professional: Skills, trends and career paths...How to stay relevant as a cyber professional: Skills, trends and career paths...
How to stay relevant as a cyber professional: Skills, trends and career paths...
Infosec
 
(T.L.E.) Agriculture: "Ornamental Plants"
(T.L.E.) Agriculture: "Ornamental Plants"(T.L.E.) Agriculture: "Ornamental Plants"
(T.L.E.) Agriculture: "Ornamental Plants"
MJDuyan
 
220711130082 Srabanti Bag Internet Resources For Natural Science
220711130082 Srabanti Bag Internet Resources For Natural Science220711130082 Srabanti Bag Internet Resources For Natural Science
220711130082 Srabanti Bag Internet Resources For Natural Science
Kalna College
 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
Kalna College
 
Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...
Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...
Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...
biruktesfaye27
 
220711130095 Tanu Pandey message currency, communication speed & control EPC ...
220711130095 Tanu Pandey message currency, communication speed & control EPC ...220711130095 Tanu Pandey message currency, communication speed & control EPC ...
220711130095 Tanu Pandey message currency, communication speed & control EPC ...
Kalna College
 
managing Behaviour in early childhood education.pptx
managing Behaviour in early childhood education.pptxmanaging Behaviour in early childhood education.pptx
managing Behaviour in early childhood education.pptx
nabaegha
 
Diversity Quiz Finals by Quiz Club, IIT Kanpur
Diversity Quiz Finals by Quiz Club, IIT KanpurDiversity Quiz Finals by Quiz Club, IIT Kanpur
Diversity Quiz Finals by Quiz Club, IIT Kanpur
Quiz Club IIT Kanpur
 
Keynote given on June 24 for MASSP at Grand Traverse City
Keynote given on June 24 for MASSP at Grand Traverse CityKeynote given on June 24 for MASSP at Grand Traverse City
Keynote given on June 24 for MASSP at Grand Traverse City
PJ Caposey
 
Erasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES CroatiaErasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES Croatia
whatchangedhowreflec
 
The basics of sentences session 8pptx.pptx
The basics of sentences session 8pptx.pptxThe basics of sentences session 8pptx.pptx
The basics of sentences session 8pptx.pptx
heathfieldcps1
 
What are the new features in the Fleet Odoo 17
What are the new features in the Fleet Odoo 17What are the new features in the Fleet Odoo 17
What are the new features in the Fleet Odoo 17
Celine George
 
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
220711130100 udita Chakraborty  Aims and objectives of national policy on inf...220711130100 udita Chakraborty  Aims and objectives of national policy on inf...
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
Kalna College
 
Library news letter Kitengesa Uganda June 2024
Library news letter Kitengesa Uganda June 2024Library news letter Kitengesa Uganda June 2024
Library news letter Kitengesa Uganda June 2024
Friends of African Village Libraries
 
How to Create User Notification in Odoo 17
How to Create User Notification in Odoo 17How to Create User Notification in Odoo 17
How to Create User Notification in Odoo 17
Celine George
 

Recently uploaded (20)

78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
 
220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
 
Brand Guideline of Bashundhara A4 Paper - 2024
Brand Guideline of Bashundhara A4 Paper - 2024Brand Guideline of Bashundhara A4 Paper - 2024
Brand Guideline of Bashundhara A4 Paper - 2024
 
Observational Learning
Observational Learning Observational Learning
Observational Learning
 
How to stay relevant as a cyber professional: Skills, trends and career paths...
How to stay relevant as a cyber professional: Skills, trends and career paths...How to stay relevant as a cyber professional: Skills, trends and career paths...
How to stay relevant as a cyber professional: Skills, trends and career paths...
 
(T.L.E.) Agriculture: "Ornamental Plants"
(T.L.E.) Agriculture: "Ornamental Plants"(T.L.E.) Agriculture: "Ornamental Plants"
(T.L.E.) Agriculture: "Ornamental Plants"
 
220711130082 Srabanti Bag Internet Resources For Natural Science
220711130082 Srabanti Bag Internet Resources For Natural Science220711130082 Srabanti Bag Internet Resources For Natural Science
220711130082 Srabanti Bag Internet Resources For Natural Science
 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
 
Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...
Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...
Ethiopia and Eritrea Eritrea's journey has been marked by resilience and dete...
 
220711130095 Tanu Pandey message currency, communication speed & control EPC ...
220711130095 Tanu Pandey message currency, communication speed & control EPC ...220711130095 Tanu Pandey message currency, communication speed & control EPC ...
220711130095 Tanu Pandey message currency, communication speed & control EPC ...
 
managing Behaviour in early childhood education.pptx
managing Behaviour in early childhood education.pptxmanaging Behaviour in early childhood education.pptx
managing Behaviour in early childhood education.pptx
 
Diversity Quiz Finals by Quiz Club, IIT Kanpur
Diversity Quiz Finals by Quiz Club, IIT KanpurDiversity Quiz Finals by Quiz Club, IIT Kanpur
Diversity Quiz Finals by Quiz Club, IIT Kanpur
 
Keynote given on June 24 for MASSP at Grand Traverse City
Keynote given on June 24 for MASSP at Grand Traverse CityKeynote given on June 24 for MASSP at Grand Traverse City
Keynote given on June 24 for MASSP at Grand Traverse City
 
Erasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES CroatiaErasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES Croatia
 
The basics of sentences session 8pptx.pptx
The basics of sentences session 8pptx.pptxThe basics of sentences session 8pptx.pptx
The basics of sentences session 8pptx.pptx
 
What are the new features in the Fleet Odoo 17
What are the new features in the Fleet Odoo 17What are the new features in the Fleet Odoo 17
What are the new features in the Fleet Odoo 17
 
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
220711130100 udita Chakraborty  Aims and objectives of national policy on inf...220711130100 udita Chakraborty  Aims and objectives of national policy on inf...
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
 
Library news letter Kitengesa Uganda June 2024
Library news letter Kitengesa Uganda June 2024Library news letter Kitengesa Uganda June 2024
Library news letter Kitengesa Uganda June 2024
 
How to Create User Notification in Odoo 17
How to Create User Notification in Odoo 17How to Create User Notification in Odoo 17
How to Create User Notification in Odoo 17
 

Switches and LEDs interface to the 8051 microcontroller

  • 1. Switches and LEDs Interface to the 8051 Microcontroller Prepared by: Afrah Salman
  • 2. Switch Basics • A switch is an electrical component that can break an electrical circuit, interrupting the current or diverting it from one conductor to another. • If we directly connect a switch to one of the microcontroller port pins, the pin floats when the switch is open. Meaning, it is not at a fixed logic level 0v or 5v.
  • 3.
  • 5. Interfacing Switch • Fig. 1 shows how to interface the switch to microcontroller. A simple switch has an open state and closed state. However, a microcontroller needs to see a definite high or low voltage level at a digital input. A switch requires a pull-up or pull-down resistor to produce a definite high or low voltage when it is open or closed. A resistor placed between a digital input and the supply voltage is called a "pull-up" resistor because it normally pulls the pin's voltage up to the supply.
  • 7. LED Basics • Light Emitting Diodes are the semi conductor light sources. Commonly used LEDs will have a cut-off voltage of 1.7V and current of 10mA. When an LED is applied with its required voltage and current it glows with full intensity. The Light Emitting Diode is similar to the normal PN diode but it emits energy in the form of light. The color of light depends on the band gap of the semiconductor.
  • 8.
  • 9. Interface to the Microcontroller • Now we could go ahead and interface it to the microcontroller, but we would rather interface 8 switches and 8 LED's to two ports as shown in the schematic below.
  • 10.
  • 11. • As we can see the schematic has basic circuits for oscillator, reset and power connections for the microcontroller. • A DIP (dual in line package) Switch, array of 8 switches is connected to PORT3 AND 8 LEDs toPORT2. • Observe the RR1 component, it is array of 8 resistors in a single pack(SIP). It is as good as connecting 8 pull-up resistors as shown in figure 1. You could also use 8 discrete resistors as well.
  • 12. Interfacing Switch with 8051 • We now want to control the LED by using switches in 8051 Slicker Board. It works by turning ON a LED & then turning it OFF when switch is going to LOW or HIGH. The 8051 Slicker board has eight numbers of point LEDs, connected with I/O Port lines (P0.0 – P0.7) to make port pins high. Eight switches, connected with I/O port lines (P2.0 – P2.7) are used to control eight LEDs.
  • 13. Circuit Diagram to Interface Switch with 8051
  • 14. Example1:The following program will make the value of PIN3.1 keeps toggling (ON/OFF) after some delay. org 00H ;MAIN PROGRAM Toggle: MOV P3, #01H ;move 00000001 to PORT3 CALL delay ;execute delay MOV A, P3 ;move PORT3 value to accumulator CPL A ;complement PORT3 value MOV P3, A ;move 11111110 to PORT3 CALL delay ;execute delay SJMP Toggle
  • 15. ;DELAY SUB-ROUTINE delay: MOV R5, #10 ;load register R5 with 10 third: MOV R6, #200 ;load register R6 with 200 second: MOV R7, #200 ;load register R7 with 200 DJNZ R7, $ ;decrement R7 till it is zero DJNZ R6, second ;decrement R6 till it is zero DJNZ R5, third ;decrement R5 till it is zero ret ;go back to main program END
  • 16. Example2:Aswitch is connected to pin PI .7. Write a program to check the status of SW and perform the following: If SW=0, send letter ‘N’ to P2., If SW=1, send letter ‘Y’ to P2. org 00H ;MAIN PROGRAM SETB P1.7 ;make P1.7 an input AGAIN: JB P1.2, OVER ;jump if P1.7=1 MOV P2, #’N’ ;SW=0, issue ‘N’ to P2 SJMP AGAIN ;keep monitoring OVER: MOV P2,#’Y’ ;SW=1, issue ‘Y’ to P2 SJMP AGAIN ;keep monitoring
  • 17. Example3:Aswitch is connected to pin PI .7 and an LED to pin P2.7. Write a program to get the status of the switch and send it to the LED. org 00H ;MAIN PROGRAM SETB P1.7 ;make P1.7 an input AGAIN: MOV C,P1.0 ;read the SW status into CF MOV P2.7, C ;send the SW status to LED SJMP AGAIN ;keep repeating Note: The instruction “MOV P2.7, P1.0” is wrong since such an instruction doesn’t exist. However, “MOV P2, P1” is a valid instruction.
  翻译: