Interfacing Slide
Switch and LED
with 8051
www.pantechsolutions.net
SWITCH AND LED INTERFACEWITH
8051
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt
SWITCH LED INTERFACE
• ASSEMBLY
Org 30h
Start: JB P0.0,LED1
JB P0.0,LED2
JB P0.0,LED3
JB P0.0,LED4
JB P0.0,LED5
JB P0.0,LED6
JB P0.0,LED7
JB P0.0,LED8
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt
SWITCH LED INTERFACE
LED1: SETB P0.0
LED2: SETB P0.0
LED3: SETB P0.0
LED4: SETB P0.0
LED5: SETB P0.0
LED6: SETB P0.0
LED7: SETB P0.0
LED8: SETB P0.0
Sjmp :start
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt
SWITCH LED INTERFACE
#include<reg51.h> //Define 8051 Registers
#define SW P0 //Define Switch to Port0
#define Led P0 //Define Led to Port0
void main()
{
// P=0xff; //Port-0 as input to FFh
//P0=0x00; //Port-0 as output to 00h
while(1) //Loop Forever
{
Led = SW; //Assign the Switch value to Led
}
}
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt
For More Tutorials
www.pantechsolutions.net
http://www.slideshare.net/pantechsolutions
http://www.scribd.com/pantechsolutions
http://www.youtube.com/pantechsolutions
Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt