LED Blinking Using 8051

--> LED Blinking Using 8051 -Proteus Simulation Tutorials
AT89C51 is an 8-bit micro-controller and belongs to Atmel's 8051 family. AT89C51 has 4KB of Flash programmable and erasable read only memory (P-EROM) and 128 bytes of RAM. It can be erased and program to a maximum of 1000 times.

In 40 pin AT89C51, there are four ports designated as P1, P2, P3 and P0. All these ports are 8-bit bi-directional ports, i.e., they can be used as both input and output ports. Except P0 which needs external pull-ups, rest of the ports have internal pull-ups. When 1s are written to these port pins, they are pulled high by the internal pull-ups and can be used as inputs. These ports are also bit addressable and so their bits can also be accessed individually.

Port P0 and P2 are also used to provide low byte and high byte addresses, respectively, when connected to an external memory. Port 3 has multiplexed pins for special functions like serial communication, hardware interrupts, timer inputs and read/write operation from external memory. AT89C51 has an inbuilt UART for serial communication. It can be programmed to operate at different baud rates. Including two timers & hardware interrupts, it has a total of six interrupts.

One can read datasheets for detailed knowledge.

Lets start with our first program to blink the LED's at the PORT-0 of the Micro-Controller.
Note that these programs are made in Keil u Vision 3

#include <REGX51.H> // Header file

void Delay(unsigned char i); // Function calling

void main()

P0 = 0x00;                               //PORT 0 as Output Port

while (1) {

P0 = 0xAA;                           // 10101010


P0 = 0x55;                           // 010101010



void Delay(unsigned char itime)


unsigned char i;

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


  1. Now put the generated *.hex files in the micro-controller's memory and view the result, the output is shown below.
Any doubt Please mail me i will help you thannara123(at)gmail.com

Post a Comment




Contact Form


Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget