top of page

Blinking LED Using 8051 controller 

By Devanshu Singhal

Introduction

                          First 8051 is developed by Intel in 1980's & it is based on Harvard Architecture and developed primarily for use in embedded systems technology. 8051 is 40 pin dual in package ic and it is 8 bit micro-controller with 4 i/o port (each port having 8 bit)
led is commonly known as light emitting diode and it available in many dimensions like 3mm, 5mm ,10mm.
The voltage range of led is lie in between 1.2v to 3.0v and the maximum value of current is 16 milli-amp.
& their is two terminal in led one is cathode & other one is anode. 
As in led blinking project we connect our led with micro controller and with help of coding we do 

Working

                So far we said that the blinking of an LED is done using the important registers:

      

  • PORT register: is used to give the state of a pin connected to a port of a 8051 micro-controller, if we want the toggle a pin of a port this register is responsible. if you desire to put a pin high you need to assign 1 and 0 for low state. If for example you want to switch ON the test LED connected to port B you can write as in binary representation: PORTB =0b0000001 and Hexadecimal representation: PORTB = 0x02

LEDs

                    The circuit diagram shown below has the following elements but in case you are working with our Board you don't need to add components.

  • a resistor of value 4k7 ohm is connected in series with +5 volt and the reset pin (1st pin)

  • Q1 is the crystal oscillator in this case its frequency oscillation is 20 MHz.

  • supply: the circuit is connected with a voltage maximum equal 5 volt

  • R3 is a limiting current resistor to protect the LED.

  • C1 & C2 are of 22pF.

Circuit Diagram

Code and Comment

#include<reg51.h>

void delay()

   {

     int i;

     for(i=0;i<=20;i++)

         {

               TMOD=0x01;

               TL0=0x80;

               TH0=0x3C;

               TR0=1;

               while(TF0==0);

               TR0=0;

               TF0=0;

              }

            }

    void main()

  {

     P1=0x00;

     delay();

     P1=0xff;

     delay();

}

bottom of page