LED Chaser using PIC Microcontroller

LED Chaser using PIC Microcontroller

LED Chaser is a simple project for beginners that can build using PIC microcontroller. In this 8 LED are running like a Ring Counter. It is very simple and you can create different patterns as you like just by modifying the MikroC program. Here I am using PIC16F877A, one of the most popular PIC microcontroller.

This tutorial is on the assumption that, you have basic knowledge in mikroC and Proteus. If you haven’t please go to this tutorial.

MikroC Code

void main()
  CMCON = 0x07; // To turn off comparators
  ADCON1 = 0x06; // To turn off adc
  TRISB = 0x00; // Sets all pins in PORTB as output
  PORTB = 1; // Set RB0 to high 00000001
  do // To set infinite loop
    Delay_ms(300); // 300 mili seconds delay
    PORTB = PORTB<<1; //Shifting right by one bit
    if(PORTB >= 0b10000000) //To reset to 00000001
    {                          //when the count becomes 10000000
       Delay_ms(350); // 350 mili seconds delay
       PORTB = 1;
  }while(1); // To set infinite loop

Here we first set the output of PORTB as 0000001, then by shifting we get 00000010, 00000100….. When the count reaches 10000000 we reset it to 00000001 in the conditional block.

Circuit Diagram

Note: VDD and VSS of the pic microcontroller is not shown in the circuit diagram. VDD should be connected to +5V and VSS to GND.

LED is connected in series with a resistor of 1K ohm to limit the current through it.

Download Here

You can download the Hex file, MikroC file, Proteus etc from here…

Share this post