Multiple Blinking LED using PIC16F877A with Proteus Simulation

Recommended To Know before you go to this tutorial

1. How to configure PIC16F77A as a GPIO
2. Simple Blinking LED tutorial with PIC16F77A

Multiple Blinking LED Tutorial

In this tutorial Blue, Green, Red, Yellow these 4 LEDs are turned on and off with some delay. It is one of the application of GPIO configuration.

Embedded C Program

#include <xc.h>
void main(void) {
    //PORTA pin 0 as output
    //Direction register configuration
    TRISA = 0;
    //Initialize the variable
    //used for the delay
    int i = 0;
    //loop for ever
    while(1)
    {
       //LED 4 OFF
       RA3 = 0;      
       //LED 1 ON
       RA0 = 1;
       //Delay function
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);
       //LED 1 OFF
       RA0 = 0;
       //LED 2 ON
       RA1 = 1;
       //Delay
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);
       //LED 2 OFF
       RA1 = 0;      
       //LED 3 ON
       RA2 = 1;
       //Delay function
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);

       //LED 3 OFF
       RA2 = 0;
       //LED 4 ON
       RA3 = 1;
       //Delay
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);
       for(i = 1; i< 6000; i++);

    }
    return;
}

Proteus Hardware simulation Circuit


Proteus Simulation Output





Here, All the LED's are turned on and off one by one with some delay.

Video Tutorial


Also See Multiple Bliking LED for 8051

3 comments:

  1. I was getting bore since morning but as soon as I got this link & reached at this blog, I turned into fresh and also joyful too.
    find

    ReplyDelete
  2. Rapidly this kind of fantastic web site will surely irrefutably often be well-known amongst many creating any website people, due to the fact thorough articles along with testimonies. visit here

    ReplyDelete
  3. Best Corporate Video Production Company in Bangalore and top Explainer Video Company, 3d, 2d Animation Video Makers in Chennai
    Excellent article. Good tips! Fantastic stuff!

    ReplyDelete