SlideShare a Scribd company logo
RELAY INTERFACING WITH
8051
PRATIK PHADTE
COURSE : ELECTRICAL AND ELECTRONICS ENGINEERING
@pratikphadte19@gmail.com
TOPICS
• What`s a relay
• Interfacing relay with 8051
• Assembly code for interfacing
• C code for interfacing
WHAT`S A RELAY
• A relay is nothing but a switch, it can be controlled(ON/OFF) by a low power signal(ex:
current in microamps).
• Its mainly used as a switch in high power circuits(230v,50hz).
• When control signal is given
(ex:HIGH) ,then the switch is
CLOSED
• Similarly when control signal is
LOW ,then switch in OPEN
WHAT`S A RELAY
• The figure shows practical internal
operation of a relay.
• Here ,when the small switch is closed ,the coil gets
energized becoming an ELECTROMAGNET
• Thus ,attracting the metallic plate and hence
CLOSING the main switch.
• When the small switch is open, the coil is
de-energized ,hence the SPRING pulls the
metallic plate back therefore OPENING the
main switch.
INTERFACING RELAY WITH 8051
For interfacing with the controller we need a setup like below:
• Here the 8051 uc can be programmed to
to set its any port pin as output(HIGH/LOW
(one /zero)
• A HIGH signal from port pin P0.1 will turn o
transistor and energize the coil, hence MAIN
switch will CLOSE thus the bulb GLOWS.
• When LOW signal is given by 8051 uc ,
the transistor is off and the coil gets
de-energized via the free wheeling diode
hence the metallic plate is lifted and
main switch is OPEN.
ASSEMBLY CODE FOR INTERFACING
For assembly code we need to just send a high signal to the used Port PIN
High signal=LOGIC ONE
CODE:
org 00h
setb P0.2 [output of port zero pin two is set to HIGH(one)]
acall delay
clr P0.2 [output of port zero pin two is set to LOW(zero)]
END
NOTE: delay code is not mentioned here
C CODE FOR INTERFACING
#include<reg52.h>
sbit relay_pin = P0^2; [naming port zero pin two]
Void delay(int); [Define delay function]
Void main( )
{
do
{
relay_pin=0; [relay switched ON]
delay( );
relay_pin=1; [relay switched ON]
delay( );
} while(1);
}
NOTE: delay code is not mentioned here

More Related Content

What's hot

8051 i/o port circuit
8051 i/o port circuit8051 i/o port circuit
8051 i/o port circuit
dharmendrawaghjipur007
 
OP AMP Applications
OP AMP ApplicationsOP AMP Applications
OP AMP Applications
aroosa khan
 
MOSFETs
MOSFETsMOSFETs
MOSFETs
A B Shinde
 
Op amp
Op ampOp amp
Interfacing adc
Interfacing adcInterfacing adc
Interfacing adcPRADEEP
 
Microcontroller 8051 and its interfacing
Microcontroller 8051 and its interfacingMicrocontroller 8051 and its interfacing
Microcontroller 8051 and its interfacing
Ankur Mahajan
 
Memory organization of 8051
Memory organization of 8051Memory organization of 8051
Memory organization of 8051Muthu Manickam
 
8051 Microcontroller ppt
8051 Microcontroller ppt8051 Microcontroller ppt
8051 Microcontroller ppt
Rahul Kumar
 
R-2R Ladder DAC
R-2R Ladder DACR-2R Ladder DAC
R-2R Ladder DAC
Chandul4y
 
Op amp(operational amplifier)
Op amp(operational amplifier)Op amp(operational amplifier)
Op amp(operational amplifier)
Kausik das
 
LPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERLPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLER
sravannunna24
 
Pulse width modulation (PWM)
Pulse width modulation (PWM)Pulse width modulation (PWM)
Pulse width modulation (PWM)
amar pandey
 
I/O port programming in 8051
I/O port programming in 8051I/O port programming in 8051
I/O port programming in 8051
ssuser3a47cb
 
Hybrid Parameter in BJT
Hybrid Parameter in BJTHybrid Parameter in BJT
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051
hello_priti
 
Silicon control rectifier
Silicon control rectifierSilicon control rectifier
Silicon control rectifier
Mozammel Hoque Parvez
 
Choppers
ChoppersChoppers
Phase Locked Loop (PLL)
Phase Locked Loop (PLL)Phase Locked Loop (PLL)
Phase Locked Loop (PLL)
Debayon Saha
 
Operational amplifier
Operational amplifierOperational amplifier
Operational amplifier
Unsa Shakir
 
DAC Interfacing with 8051.pdf
DAC Interfacing with 8051.pdfDAC Interfacing with 8051.pdf
DAC Interfacing with 8051.pdf
Srikrishna Thota
 

What's hot (20)

8051 i/o port circuit
8051 i/o port circuit8051 i/o port circuit
8051 i/o port circuit
 
OP AMP Applications
OP AMP ApplicationsOP AMP Applications
OP AMP Applications
 
MOSFETs
MOSFETsMOSFETs
MOSFETs
 
Op amp
Op ampOp amp
Op amp
 
Interfacing adc
Interfacing adcInterfacing adc
Interfacing adc
 
Microcontroller 8051 and its interfacing
Microcontroller 8051 and its interfacingMicrocontroller 8051 and its interfacing
Microcontroller 8051 and its interfacing
 
Memory organization of 8051
Memory organization of 8051Memory organization of 8051
Memory organization of 8051
 
8051 Microcontroller ppt
8051 Microcontroller ppt8051 Microcontroller ppt
8051 Microcontroller ppt
 
R-2R Ladder DAC
R-2R Ladder DACR-2R Ladder DAC
R-2R Ladder DAC
 
Op amp(operational amplifier)
Op amp(operational amplifier)Op amp(operational amplifier)
Op amp(operational amplifier)
 
LPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERLPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLER
 
Pulse width modulation (PWM)
Pulse width modulation (PWM)Pulse width modulation (PWM)
Pulse width modulation (PWM)
 
I/O port programming in 8051
I/O port programming in 8051I/O port programming in 8051
I/O port programming in 8051
 
Hybrid Parameter in BJT
Hybrid Parameter in BJTHybrid Parameter in BJT
Hybrid Parameter in BJT
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051
 
Silicon control rectifier
Silicon control rectifierSilicon control rectifier
Silicon control rectifier
 
Choppers
ChoppersChoppers
Choppers
 
Phase Locked Loop (PLL)
Phase Locked Loop (PLL)Phase Locked Loop (PLL)
Phase Locked Loop (PLL)
 
Operational amplifier
Operational amplifierOperational amplifier
Operational amplifier
 
DAC Interfacing with 8051.pdf
DAC Interfacing with 8051.pdfDAC Interfacing with 8051.pdf
DAC Interfacing with 8051.pdf
 

Similar to Relay interfacing with 8051

Clap switch mini project using 555 timer IC
Clap switch mini project using 555 timer ICClap switch mini project using 555 timer IC
Clap switch mini project using 555 timer IC
Erole technologies Pvt. Ltd
 
digitalelectronicslogicfamilies-190628101225-converted.pptx
digitalelectronicslogicfamilies-190628101225-converted.pptxdigitalelectronicslogicfamilies-190628101225-converted.pptx
digitalelectronicslogicfamilies-190628101225-converted.pptx
Bijay Sharma
 
Digital electronics logic families
Digital electronics logic familiesDigital electronics logic families
Digital electronics logic families
BLESSINAR0
 
Digital integrated circuits
Digital integrated circuitsDigital integrated circuits
Digital integrated circuits
Tamilarasan N
 
Unit5 session 5
Unit5 session 5Unit5 session 5
Unit5 session 5
SIVALAKSHMIPANNEERSE
 
Unit 5 session 4
Unit 5 session 4Unit 5 session 4
Unit 5 session 4
SIVALAKSHMIPANNEERSE
 
Unit 5 session 4
Unit 5 session 4Unit 5 session 4
Unit 5 session 4
SIVALAKSHMIPANNEERSE
 
L6561 Power Factor Corrector
L6561 Power Factor CorrectorL6561 Power Factor Corrector
L6561 Power Factor Corrector
Premier Farnell
 
Logic families ppt eceb srp
Logic families ppt eceb srpLogic families ppt eceb srp
Logic families ppt eceb srp
Saikat Dutt
 
Logic not gate tutorial with logic gate truth table
Logic not gate tutorial with logic gate truth tableLogic not gate tutorial with logic gate truth table
Logic not gate tutorial with logic gate truth table
guru nanak institute of technology
 
Logic Gates & Family.pdf
Logic Gates & Family.pdfLogic Gates & Family.pdf
Logic Gates & Family.pdf
DanishKhan313548
 
UNIT 3.pptx
UNIT 3.pptxUNIT 3.pptx
UNIT 3.pptx
ssuser022fec
 
Original Power Supply IC TNY254PN TNY254P TNY254 New
Original Power Supply IC TNY254PN TNY254P TNY254 NewOriginal Power Supply IC TNY254PN TNY254P TNY254 New
Original Power Supply IC TNY254PN TNY254P TNY254 New
AUTHELECTRONIC
 
Switches and LEDs interface to the 8051 microcontroller
Switches and LEDs interface to the 8051 microcontrollerSwitches and LEDs interface to the 8051 microcontroller
Switches and LEDs interface to the 8051 microcontroller
University of Technology - Iraq
 
Logic families
Logic familiesLogic families
Logic families
SARITHA REDDY
 
PLC
PLCPLC
Logic families
Logic familiesLogic families
Logic families
JAGDEEPSAINI10
 
Introduction to Integrated Circuits
Introduction to Integrated CircuitsIntroduction to Integrated Circuits
Introduction to Integrated Circuits
Gurpawan Mand
 
34866616-Relay.ppt
34866616-Relay.ppt34866616-Relay.ppt
34866616-Relay.ppt
MozammelHossain31
 
Digital logic, an inverter or NOT gate
Digital logic, an inverter or NOT gateDigital logic, an inverter or NOT gate
Digital logic, an inverter or NOT gate
Roorkee College of Engineering, Roorkee
 

Similar to Relay interfacing with 8051 (20)

Clap switch mini project using 555 timer IC
Clap switch mini project using 555 timer ICClap switch mini project using 555 timer IC
Clap switch mini project using 555 timer IC
 
digitalelectronicslogicfamilies-190628101225-converted.pptx
digitalelectronicslogicfamilies-190628101225-converted.pptxdigitalelectronicslogicfamilies-190628101225-converted.pptx
digitalelectronicslogicfamilies-190628101225-converted.pptx
 
Digital electronics logic families
Digital electronics logic familiesDigital electronics logic families
Digital electronics logic families
 
Digital integrated circuits
Digital integrated circuitsDigital integrated circuits
Digital integrated circuits
 
Unit5 session 5
Unit5 session 5Unit5 session 5
Unit5 session 5
 
Unit 5 session 4
Unit 5 session 4Unit 5 session 4
Unit 5 session 4
 
Unit 5 session 4
Unit 5 session 4Unit 5 session 4
Unit 5 session 4
 
L6561 Power Factor Corrector
L6561 Power Factor CorrectorL6561 Power Factor Corrector
L6561 Power Factor Corrector
 
Logic families ppt eceb srp
Logic families ppt eceb srpLogic families ppt eceb srp
Logic families ppt eceb srp
 
Logic not gate tutorial with logic gate truth table
Logic not gate tutorial with logic gate truth tableLogic not gate tutorial with logic gate truth table
Logic not gate tutorial with logic gate truth table
 
Logic Gates & Family.pdf
Logic Gates & Family.pdfLogic Gates & Family.pdf
Logic Gates & Family.pdf
 
UNIT 3.pptx
UNIT 3.pptxUNIT 3.pptx
UNIT 3.pptx
 
Original Power Supply IC TNY254PN TNY254P TNY254 New
Original Power Supply IC TNY254PN TNY254P TNY254 NewOriginal Power Supply IC TNY254PN TNY254P TNY254 New
Original Power Supply IC TNY254PN TNY254P TNY254 New
 
Switches and LEDs interface to the 8051 microcontroller
Switches and LEDs interface to the 8051 microcontrollerSwitches and LEDs interface to the 8051 microcontroller
Switches and LEDs interface to the 8051 microcontroller
 
Logic families
Logic familiesLogic families
Logic families
 
PLC
PLCPLC
PLC
 
Logic families
Logic familiesLogic families
Logic families
 
Introduction to Integrated Circuits
Introduction to Integrated CircuitsIntroduction to Integrated Circuits
Introduction to Integrated Circuits
 
34866616-Relay.ppt
34866616-Relay.ppt34866616-Relay.ppt
34866616-Relay.ppt
 
Digital logic, an inverter or NOT gate
Digital logic, an inverter or NOT gateDigital logic, an inverter or NOT gate
Digital logic, an inverter or NOT gate
 

Recently uploaded

Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 

Recently uploaded (20)

Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 

Relay interfacing with 8051

  • 1. RELAY INTERFACING WITH 8051 PRATIK PHADTE COURSE : ELECTRICAL AND ELECTRONICS ENGINEERING @pratikphadte19@gmail.com
  • 2. TOPICS • What`s a relay • Interfacing relay with 8051 • Assembly code for interfacing • C code for interfacing
  • 3. WHAT`S A RELAY • A relay is nothing but a switch, it can be controlled(ON/OFF) by a low power signal(ex: current in microamps). • Its mainly used as a switch in high power circuits(230v,50hz). • When control signal is given (ex:HIGH) ,then the switch is CLOSED • Similarly when control signal is LOW ,then switch in OPEN
  • 4. WHAT`S A RELAY • The figure shows practical internal operation of a relay. • Here ,when the small switch is closed ,the coil gets energized becoming an ELECTROMAGNET • Thus ,attracting the metallic plate and hence CLOSING the main switch. • When the small switch is open, the coil is de-energized ,hence the SPRING pulls the metallic plate back therefore OPENING the main switch.
  • 5. INTERFACING RELAY WITH 8051 For interfacing with the controller we need a setup like below: • Here the 8051 uc can be programmed to to set its any port pin as output(HIGH/LOW (one /zero) • A HIGH signal from port pin P0.1 will turn o transistor and energize the coil, hence MAIN switch will CLOSE thus the bulb GLOWS. • When LOW signal is given by 8051 uc , the transistor is off and the coil gets de-energized via the free wheeling diode hence the metallic plate is lifted and main switch is OPEN.
  • 6. ASSEMBLY CODE FOR INTERFACING For assembly code we need to just send a high signal to the used Port PIN High signal=LOGIC ONE CODE: org 00h setb P0.2 [output of port zero pin two is set to HIGH(one)] acall delay clr P0.2 [output of port zero pin two is set to LOW(zero)] END NOTE: delay code is not mentioned here
  • 7. C CODE FOR INTERFACING #include<reg52.h> sbit relay_pin = P0^2; [naming port zero pin two] Void delay(int); [Define delay function] Void main( ) { do { relay_pin=0; [relay switched ON] delay( ); relay_pin=1; [relay switched ON] delay( ); } while(1); } NOTE: delay code is not mentioned here