Led Interfacing with 8051 Microcontroller

By | June 28, 2015

In this post, we will explore the LED interfacing with 8051 Microcontroller.

LED stands for Light Emitting Diode. It’s a diode which can able to emit light. LEDs are pretty commonly used in the embedded devices to get indications, feedback, notifications.

In this project, we will interface 8 LED to 8051 microcontroller and blink them alternatively with some delay and repeat them for ever. To get idea on the result of the project, you can watch video at the  end of this post.

In the up coming posts, we will also see the some advanced interfacings such as LED display, LED 7 – segment interfacing, RGB LED interfacing, Changing the brightness of LED, etc ..

Typical 8051 LED interfacing project setup :

This is my development board specially designed for http://www.embeddedforu.com/ to demonstrate projects and interfacing with different microcontroller.

On the right hand side of the board, there is a 8051 microcontroller reset circuit. Also burgstrips connected to each miconcontroller ports for easy external component connections.

On the left hand middle, we have LED setup. There are total 9 LEDs available, out of 9 LEDs, 8 LEDs are Active LOW and 1 LED is Active HIGH.

8051 reset Circuit and LED set are enough to complete this project, we will discuss about other components later.

Led interfacing with 8051 microcontroller - Image


8051 LED interfacing – Blocks

As you can see in the below image, this project can be divided in to three major block.

8051 LED interfacing Block diagram

Power supply :

This block provides the power to our project. 8051 can only withstand upto 5.5 DC volts max. Typical voltage is 5.0v DC. So this block should provide a constant 5.0v to microcontroller. There are several option to do this.

Best way is to use a 12V 1A DC adapter along with 7805 DC voltage regulator. 7805 converts 7V – 30V DC input voltage to 5V DC output. In this way, you can provide 5V to microcontroller and 12 V to other system components if required.

LED Block :


Stand alone 8051 reset circuit:

This is a typical reset and oscillator circuit of our projects. There will be a special post discussing about this part of the project. TBD

8051-standalone reset circuit



8051 LED interfacing – code

 * Project : LED interfacing with 8051 Microcontroller
 * Description : In this project, I will be interfacing 
 *               8 LEDs to a 8051 microcontroller.
 * Software : Keil uVison4
 * MCU : AT89S51/S52/C51/C52
 * Oscillator : 11.0592 Mhz
 * Date : 27-April-2015

#include <reg51.h>

#define PORT1 P1

void Delay(int );

void Delay(int i)
    int j;
    for(; i; i--)
    for(j=160; j; j--);

void main()
while(1) /* For ever */
    PORT1 = 0x55;  /* 0101 0101 to PORT 1 */
    Delay( 500 );  /* delay */
    PORT1 = 0xAA;  /* 1010 1010 to PORT 1 */
    Delay( 500 );  /* delay */
/*    The End     */


 8051 LED interfacing – circuit


8051 Led interfacing Circuit


8051 LED interfacing – Video demo


Leave a Reply

Your email address will not be published. Required fields are marked *