8051 Microcontroller manufacturers have been competing for a long time for attracting choosy customers and every couple of days a new chip with a higher operating frequency, more memory and upgraded A/D converters appeared on the market.

However, most of them had the same or at least very similar architecture known in the world of microcontrollers as “8051 compatible”. The main reason for their great success and popularity is a skillfully chosen configuration which satisfies different needs of a large number of users allowing at the same time constant expansions (refers to the new types of microcontrollers). Besides, the software has been developed in great extend in the meantime, and it simply was not profitable to change anything in the microcontroller’s basic core. This is the reason for having a great number of various microcontrollers which basically are solely upgraded versions of the 8051 family.

, ,

Keil Compiler for 8051 microcontroller

Keil Compiler is the latest release by keil software development environment for a wide range of 8051 based microcontroller devices. This includes the µVision IDE/Debugger, ASM, C/C++ Compiler, and essential middleware components. It’s easy to learn and use.

Keil development tools for the 8051 Microcontroller Architecture support every level of software developer from the professional applications engineer to the student just learning about embedded software development.
The industry-standard Keil C Compilers, Macro Assemblers, Debuggers, Real-time Kernels, Single-board Computers, and Emulators support all 8051 derivatives and help you get your projects completed on schedule.
The Keil 8051 Development Tools are designed to solve the complex problems facing embedded software developers.
Feature of Keil C51
  • When starting a new project, simply select the microcontroller you use from the Device Database and the µVision IDE sets all compiler, assembler, linker, and memory options for you.
  • Numerous example programs are included to help you get started with the most popular embedded 8051 devices.
  • The Keil µVision Debugger accurately simulates on-chip peripherals (I²C, CAN, UART, SPI, Interrupts, I/O Ports, A/D Converter, D/A Converter, and PWM Modules) of your 8051 device. Simulation helps you understand hardware configurations and avoids time wasted on setup problems. Additionally, with simulation, you can write and test applications before target hardware is available.
  • When you are ready to begin testing your software application with target hardware, use the MON51, MON390, MONADI, or FlashMON51 Target Monitors, the ISD51 In-System Debugger, or the ULINK USB-JTAG Adapter to download and test program code on your target system.


How to use Keil Software for 8051 series Microcontroller(Click Here)

Title                                                           Keil C Compiler For 8051 MCS
Filename                                                  Keil_Setup.exe
File size                                                    51.79 MB 
Requirements                                         Window/ XP / Vista / Windows 7/ Windows 8 / Windows 10
Languages                                               Multiple languages
License                                                     Freeware

Flash Magic Software

Flash Magic is an application to allow you to easily access the features of a microcontroller device. With this program you can erase individual blocks or the entire Flash memory of the microcontroller. Flash Magic is a PC tool for programming flash based 8051 & ARM & LPC series microcontrollers from NXP using a serial or Ethernet protocol while in the target hardware.
This application is very useful for those who work in the electronics field.

Using Flash Magic, you are able to perform different operations to a microcontroller device, operations like erasing, programming and reading the flash memory, modifying the Boot Vector, performing a blank check on a section of the Flash memory and many others.
How to use Flash Magic Software(Click Here)
Title                                                           Flash Magic
Filename                                                  Flashmagic.exe
File size                                                     7.29 MB
Requirements                                         Window/ XP / Vista / Windows 7/ Windows 8 / Windows 10
Languages                                               Multiple languages
License                                                     Freeware
, , , , ,

How to use Proteus for circuit design

Important: As Proteus does not bound us to connect power supply, XTAL,reset circuit,EA pin and other basic connections so we are ignoring them for sake of simplicity. The important things like Xtal frequency of micro controller can be set from properties of micro controller, as discussed below.

While in actual hardware form for you must follow basic circuit shown at very beginning of this post.
1) Open Proteus



2) Click on “P to open up part list.
Locate AT89C51 IC as shown below:




3) Locate LEDs as shown below



4) Make connections from 8051 to LEDs


5)Locate GND terminal as shown below

6) Connect all LEDs to GND

7) Double click on 8051 IC to open up its properties window.

— Set the operating frequency i-e 12.0MHz
— Give controller the desired HEX file.
8) Click on Play Button to start simulation




How to use keil software for 8051

1) As you will open Keil software , you will see following screen:



2) Create new project as shown below:



3) Name it. Make sure that you already have made the separate folder to minimize confusion of new project files with old ones. New folder will keep all files related to only to one project hence making it easy to locate files you need afterwards.



4) Select chip manufacturer, in our case Atmel then select chip model i-e AT89c51





5) Software will ask you whether to include 8051 start up code, select YES.



6) This is how you working environment should look like till now:



6) As new project folders are created, now it is time to create a text file which will include your assembly code. Go to file drop down menu and select “New” or simply click blank paper icon in file toolbar.





7) Write your code in the new white work space that just has been created.




8) It’s time to save your C code file now.
Go to file drop down menu and select save. Save the file into your main project folder.





As you will save the file, the software will detect the .C language keywords and they become colorful to make them prominent from rest of code.




9) Now you have to add .C code file to your project. Right click on the source group folder (sub-folder of main target1 folder) and select “Add files to group (source group)”



10) A small window will appear asking you for location of your .C code file. Give it the path of wherever you have saved your file, it should be in your project folder. Select the file click “Add”.




11) You may check the .C file by clicking on the little plus sign at the left of source group.


12) There are some configuration changes that you have to make before you build the final .HEX file.



-In target tab set the frequency that you are using with 8051, in our case 12MHz. So change default value 24.0MHz to 12Mhz



-In output tab check the “Create HEX file” box otherwise HEX file will not be created.

After all these settings click OK.



13) It’s now time to get final output that HEX file.

Right click on .C file which is in source group folder and select “Build target”.



14) If there are no errors in code your code will be compiled in couple of seconds showing progress in window at the bottom.

If there are errors in code then they will also be mentioned in same bottom window with number of line that contains error. You may recheck that line rectifying the mistake(s).



15) After successful compilation of code you can find final HEX file in same project folder that contains main project file/.C file/other files.





Interfacing of led with 8051 microcontroller


This tutorial gives you an introduction a very basic operation of Led to get an output from the 8051 MCS family i.e. AT89S51. As we aware that in our day to day running life Led has a wide range of useful application in almost every electronics & electrical devices like as an indicator, in TV & monitor, in electronics circuit, digital clock, watches, traffic light panel etc. Due wide applications of Led this tutorial will show the principle behind the interfacing of Led with 8051 microcontroller’s family as shown in picture below. Now we are going to interface single Led with AT89S51 microcontroller in our explanation section.


Before proceed toward the interfacing of led, we should know about the basic Led operation, principle of Led working & AT89S51 microcontroller.

So for interfacing of Led with AT89S51 microcontroller, we will use the AT89S51, which belongs to the Atmel family of 8051 series of microcontrollers, is very commonly used by a large consumer’s of hobbyist, electronics lover, engineers & project designer for learning & developing purpose. Its simplicity and easy way of programming with inbuilt features with mostly device compatibly, easily makes its position in the top preferred list of microcontroller for both new learner and experts’ user for projects.

We need a one controlling unit in our circuit which understand programming logic which is written by us. So for this we are using an 8-bit AT89S51 8051 series microcontroller which has 64 kB Flash Memory (ROM) and 1024 bytes of data RAM which operates at 11.059n Mhz crystal frequency. It is 40 Pin Package which contain 4 Ports & 8 Pin each i.e. 32 pin of Input/output Programming & rest of 8 Pin for other operation like crystal oscillator pins, reset pin, external memory pins & its operate at 5V & 60mA current we can withdraw from Pins as shown in below picture. Its supports the in serial In-System Programming (ISP). ISP feature of 8051 MCS that allows a device which reprogrammed with high speed data that transfer with software control. AT89S51 has capability to update the application firmware makes a huge range of applications in industry.

8051 pin diagram 

As we can see that from above picture that our microcontroller AT89S51 has 4 ports P0, P1, P2, P3 each port contain 8 pin for input/output operations.

As we know that Light Emitting Diodes, mainly called LEDs, which emit the light when forward biased or we can say that it emits the light when it’s excited by external power voltage source. When we applied a voltage source across the terminals of led, means +ve terminal of source to anode of led & -ve to cathode then electron & holes recombine & reaches the higher energy state and higher energy state is unstable so that it release the energy in form of light (photons).

led circuit

Most of the commonly available LEDs have dropped a voltage of 1.3 V to 2.2 V and require 7 to 10 mA to glow Led at full intensity.But our microcontroller give an output of 5V & 60mA, due to this we will connect led through the resistance of 330 ohms using below formula.

R=(Vcontroller – Vled)/I

R = (Vcc-led voltage)/current.

R = (5-1.7)/10mA.

R= 330 Ohms.

Logic to Glow the Led from AT89S51 Microcontroller.

As we already explained that led will work on forward biasing means +ve to anode & -ve to cathode of led, similar way in digital electronics +5V means HIGH or Logic 1(one) & -Ve means LOW or Logic 0(zero).


So its means when Logic 1 or HIGH applied across to anode & LOW or Logic 0 to cathode then Led will Glow.

Circuit Design

Proteus Design of Interfacing of Led with 8051 microcontroller.

In the circuit of interfacing of led with 8051, we need an AT89S51 MCS, Led, resistor 330 ohms & connecting wires. Microcontroller need a clock for proper working & synchronization, without the clock the microcontroller will not do task. Hence a Crystal oscillator of clock 11.0592 MHz is connected between two pins 19 Xtal1 and 18 Xtal2 along with two 33pf capacitors as shown in design.

Led Design

As you can refer the above circuit image. We are connecting the Led to PORT 2 Pin number 0(zero) followed by resistance 330 ohms. When we put the program into microcontroller & then give the power to circuit then Port 2 Pin 0 give Logic 1 or HIGH to Led & Led Start Glowing with full intensity.

C Code

C Programming


This program is developed by EMBEDDINATOR DEVELOPERS.


sbit LED = P2^0;  // define Port2 pin as an LED

void delay(int k)  // Delay Function


int i,j;




void main()


while(1)  // infinite loop


LED = ~LED;  //  LED Glow


}// end of while loop

} // end of main
End program

Thank you for visiting our website


, , , , ,



This tutorial gives you an explanation of following things:-

  1. What is LED & what does it’s means?
  2. Operation & Principle.
  3. Modes  & Testing.
  4. Logic to operate of LED with microcontrollers.



Light Emitting Diode, mainly called LED, It is real hero & very basic first component in the electronics & electrical world due to its lots of different jobs and are found in all kinds of devices.Among other things, they form alpha numeric numbers on digital clocks & led display, transmit information from remote controls to device, light up digital watches & tell you when your appliances are turned on or not. Combined together, they can form images on a LED television screen or illuminate a traffic light. Led are most widely used means of taking output from devices. They find wide range application as indicators while experimenting to check the validation of results at different stages. Led is very economical and easily available in electronics shops & market with variety of shape, size and colors according to requirements of user.

Principle & Operation

LED worked on Electroluminescence Principle, A LED is a p-n junction semiconductor device which emits incoherent light when biased in forward direction(the positive terminal is to be connected to the anode & negative terminal of supply is to be connected to cathode of Led). Most of the LEDs are realized using a highly doped n and a p Junction. It has two regions one is p-region and another is n-region, this two combine and make a junction. The p region is have more +ve electric charges as compare to n-region and the n region is have more -ve electric charges as compare to p-region.

Operation of Led is very simple to understand, Basically Two type of Basing in Led:-

  1.  Forward Biasing
  2. Reverse Biasing

Forward Biasing

In this mode, the positive terminal (+ve) of the cell or battery is connected to the anode of the LED & the negative terminal (-ve) is connected to the cathode terminal of the LED.

                               FORWARD BAISING OF LED

When a forward voltage +ve terminal of voltage is connected with +ve (anode) terminal of led and –ve terminal of voltage is connected with -ve (cathode) terminal of led is applied to an LED, the potential barrier of the P-N junction become smaller, then causing electron & holes recombine & reaches the higher energy state and higher energy state is unstable so that it release the energy in form of light (photons).

In short When we applied a voltage source across the terminals of led, means +ve terminal of source to anode of led & -ve to cathode then electron & holes recombine & reaches the higher energy state and higher energy state is unstable so that it release the energy in form of light (photons). This process is called electroluminescence & color of light depends on the gap between the semiconductor materials, as shown below

led circuitled circuit 1

Reverse Biasing

                               REVERSE BAISED OF LED

If LED is reverse biased, then the electrons of n-type region are pulled towards the terminal. Similarly the holes of the p-type region are pulled towards the terminal. This causes the widening of the depletion region in the p-n semiconductor. The widening of the depletion region increases the resistance of the diode so that it works as an open circuit when reverse biased.The reverse current flows due to the minority charge carriers (very few) in the semiconductors after the breakdown. The reason for the breakdown is the electric field inside the diode created by the depletion.

Testing & Determination of Led Terminals

As you can see below image of Led in which symbol & physical view is there. Now if we talk about the Led symbol on left side of picture there will be one line or plate which act as a cathode & other side is anode. Right side of image of led it has 2 legs, major one is anode & shorter one is cathode of led.

led termianls

There is another way to find cathode & anode of led by using front & top view of led as shown below. As in front view you will find two plates one thick & other is thin, so thick one cathode & thin one is anode of led.

led view

In top view of led you will find a D shape in which straight line is anode & curve shape is cathode.

One more approach to find out the terminals of led by looking the outer lower area of led, you will found there will be a cut surface in lower circle area of led, that cut area beside leg is always a cathode. Apart from this method we need volt meter & led tester for testing of led

LED CloseUp

Led Interfacing with Microcontrollers

Most of the commonly available LEDs have dropped a voltage of 1.3 V to 2.2 V and require 7 to 10 mA to glow Led at full intensity. The following picture describes “how to glow a led”.

led with cell

But we know that our most of microcontrollers give an output of 3 to 5V & 60mA corresponding to pins. If we connect Led directly to any of ports pins as shown below picture then direct 3v to 5v of the port is applied to an LED, so that LED may get damaged.

led when demage

If we connect the led as above, led will glow for very small time with high brightness and burn out. Because large current will be sink via LED from source due to high voltage. Sometimes this large current may damage our microcontrollers Port and then IC.

To limit the current allowed into LED we need to divide the voltage by adding a resistor to the circuit by finding the value of resistor according to ohm’s law.

R=(Vcontroller – Vled)/I

If we want to allow 10mA current through the LED then resistor value will be as below:-

R = (Vcc-led voltage)/current.

R = (5-1.7)/10mA.

R= 330 Ohms.

Resistor values will vary 220 ohm to 470 ohm according to value of Led voltage.

led with resistance


In above picture, we connected a 330 ohms resistor to allow 10mA current through the LED for its glow. If we reduce the value of led then will be glow brighter than previously.

Logic to Glow the LED from Microcontrollers.

As we already explained that led will work on forward biasing means +ve to anode & -ve to cathode of led, similar way in digital electronics +5V means HIGH or Logic 1(one) & -Ve means LOW or Logic 0(zero).


So its means when Logic 1 or HIGH applied across to anode & LOW or Logic 0 to cathode then Led will Glow.

Configuration of connection of led with Microcontrollers

Led operate in two configuration, because of this reason if we connect the both terminals of led to microcontroller then it consume more pin of IC & programming values also become complex in both configuration only half of pin used as compared to normal configuration & only differance in both configuration is logic .

  1. Common Cathode or Logic 1
  2. Common Anode or Logic 0

Common Cathode

Led have two terminal one +ve and second -ve.

In common cathode all the –ve terminal externally connected with Ground. And all + ve terminal connected with microcontroller.

cc config

Common Anode

Led have two terminal one +ve and  second  -ve.

In common Anode all the +ve terminal externally connected with vcc (Power Supply). And all – ve terminal connected with microcontroller.

ca config