Line 1: Line 1:
  
 
=LED Interfacing with 8051=
 
=LED Interfacing with 8051=
{{Box|type = l_green_light|text=
+
{{Box|type = l_green_light|text=<br/>
=====Introduction=====<br/>
+
=====Introduction=====
 
Light Emitting Diodes as we know are PN Junction diodes which emit light when forward biased. Well, lets say they simply emit light! They come in various packages through hole as well as SMD. They are basically used to:
 
Light Emitting Diodes as we know are PN Junction diodes which emit light when forward biased. Well, lets say they simply emit light! They come in various packages through hole as well as SMD. They are basically used to:
 
* Indicate System status, ON/OFF etc.
 
* Indicate System status, ON/OFF etc.

Revision as of 15:21, 15 December 2013

LED Interfacing with 8051


Introduction

Light Emitting Diodes as we know are PN Junction diodes which emit light when forward biased. Well, lets say they simply emit light! They come in various packages through hole as well as SMD. They are basically used to:

  • Indicate System status, ON/OFF etc.
  • LED lighting: Well, recent technology trends show a increasing usage of LEDs in domestic and industrial lighting. And there are cool projects in DIY community too. Check the Lumapad for instance.
  • Also you could build some display projects like the persistence of vision[POV].

Well, lets just start interfacing a simple LED with the micrcontroller.

Schematic Diagram
Code
/* Reg51.h contains the defnition of all ports and SFRs */
#include <reg51.h> 
#include "delay.h" 
#define LedOn 0xFF	//sending a logic one turns on the LED
#define LedOff 0x00	//sending logic zero turns it off
/* start the main program */
void main() 
{
  while(1)
    {
	 /* Turn On all the leds and wait for one second */ 
	   P0=LedOn;
	   P1=LedOn;
	   P2=LedOn;
	   P3=LedOn;
	   delay_sec(1);
	 /* Turn off all the leds and wait for one second */
	   P0=LedOff;
	   P1=LedOff;
	   P2=LedOff;
	   P3=LedOff;				   
	   delay_sec(1);
     }
}