Thursday 8 March 2018

LED and Switch interfaing with 8051



Introduction:
Here we are going to implement LED and SWITCH application using 8051 microcontroller. i.e. To turn ON/OFF LED using switch.
 If Switch ON then LED ON, and
If Switch OFF then LED OFF

Procedure:
1) Open proteus software and design the circuit as per circuit diagram.
2) Connect LED to Pin P2.0 and Switch to Pin P1.0.
3) Save the circuit.
4) Open Keil software and write the assembly program for it. Assembly program is given in blog.
5) Generate Hex file
6) Load Hex file in 8051 microcontroller in proteus.
7) Run the application.

Assembly Program:

org 00h;
led equ P2.0;     // set LED pin
switch equ P1.0;  // set Switch pin
clr switch;
up:clr led; // LED OFF
sw:jnb switch, up; // check for Switch ==1, if 1 LED ON or jump to up
setb led; // Make LED ON
sjmp sw; jump to switch check
end


Switch OFF LED OFF
Switch ON LED ON