Blinking leds using 8051 Micro-Controller


SOFTWARE: KEIL MICRO VISION 4



SIMULATOR: PROTEUS 8.0



CIRCUIT DIAGRAM:




CIRCUIT WORKING:


This project is about blinking of leds which are connected to port 1.0 and port 1.1 pins of port 1.

I have designed this circuit as a current-sinking circuit.So in order to turn ON the leds, I have provided 0V(logic 0) and for turning OFF the leds 5V(logic 1) is provided to the respective pins.


PROGRAM:


#include<reg51.h> 

sbit led1 = P1^0; 

sbit led2 = P1^1;

void delay(int d); 

void main() 

{

P1=0xfc; // set port 1.0 and port 1.1 as output 

led1=1;   // turn off the led1

led2=1; // turn off the led2

while(1) //continuous loop 

led1 = 0; // turn on the led1

led2 =1; // turn off the led 2

delay(10); // delay of 100 mili seconds 

led1=1; // turn off the led1

led2=0; // turn on the led2

delay(10); 

}

void delay(int d) // delay code 

{

int i;

for(i=0;i<d*1274;i++);

}



PROGRAM DESCRIPTION:


At starting I have make both the led's off by providing logic 1 to led1 (port1.0)and led2 (port1.1) respectively.Then for a continuous process I have used while loop.

After that I have make led1(port1.0) ON by providing logic 0 and led2(port1.1) OFF by providing logic 1.Then I have provided delay of around 100 millisecond approx.
Then again I have provided logic 1 to led 1(port1.0) to turn it OFF and logic 0 to led2 to turn it ON.


VIDEO:



Comments

Popular posts from this blog

To display custom characters on the lcd using 8051 micro-controller.

Digital Thermometer using 8051 and ADC 0808 Interfacing With 8051

LCD interfacing using AVR(ATMEGA 32)