LED Blinking using AT89C51 (Source code and Design)

LED (Light Emitting Diode) is semiconductor device which emits light when current flows. Led interfacing are of two types:

  1. Common Anode
  2. Common Cathode
Common Anode: 

Data send from cathode terminal(-ve).
All anode terminal (+ve) connected to Vcc (Power).
Send 1 to off and 0 to on the led.

Common Cathode:

Data send from Anode terminal(+ve).
All cathode terminal (-ve) connected to Ground.
Send 0 to off and 1 to on the led.

Here is the source code of led Blinking.

#include<reg51.h> // header file used for AT89C51 micro controller.

void delay(int time) //Function to create the time delay between sending 2 codes
int i,j;

void main()
while(1) // infinite loop
// P2 is defined the port of controller where data is send through. 0x is syntax to write data and 00 is the data.
P2=0x00; // 00 means all led are off.(Common Cathode) 
P2=0xff; // ff means all led are on (common Cathode)
P2=0xAA; //AA means one off and one on

Here is the circuit diagram below:

You may also like...

Leave a Reply

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