Simple Project on LED blinking by PIC 16 Microcontroller

Today I will show you how easily you can build your first project on blinking LED by using PIC 16 microcontroller. In my previous post Step by step Project guide on PIC Microcontroller I was mansion that for start-up we need

  • 1 Proteus 7 Professional (where we Make your hardware arrangement our project and simulate it to see the result)
  • 2 Mikcro C. (here we write the Embedded C Program and build the hex file of that)

Start with Proteus

  • Click on new file it will open blank work pace.
  • Now to make our project we need and add PIC 16, Crystal, Traffic light.
  • Now place this on workplace and connect them

Now question is how to do that? For that see the video which will make you understand easily.


 

Now come to Mikcro C

After making hardware arrangement you need the hex file to run the project of LED blinking. Now question is how to write the program?

First you need to know how to create new project in Mikcro C?

  • Click on New project under Project menu
  • Give your project name
  • Now most important select the device in which you work on select PIC 16F877
  • Press ok now blank page will come

See the video for how to create new project in Micro C

Now last and main question is how to write your program?

See in PIC16 four ports are available Port A, Port B, Port C, Port D. Now you have to know the procedure to define those ports as an input or output. For defining ports you can use TRIS command. Let suppose you have to define port D then your command will be TRISD.

Simple Project on LED blinking by PIC 16 Microcontroller

Now how to define port D as a input or output for that the format will be

TRISD = 1 (input)

TRISD = 0 (output)

 Now see the hardware connection, three LEDs are connected in Port D bit 0, bit 1 and bit 2 positions. So now for glow the

Upper led we have to send 00000001 = 1

Middle LED we need to send 00000010 = 2

Lower LED we need to send 00000100 = 4

So for our Simple Project on LED blinking by PIC 16 Microcontroller we have to send the number Port D =1, Port D= 2 and Port D = 4 with some delay .


Now see the embedded C program for Simple Project on LED blinking by PIC 16 Microcontroller

Embedded C Code
TRISD = 0; // Configure PORTD as output
for (i=0;i<5;i++)
{
PORTD = 1; // Initialize PORTD with value 1
Delay_ms(1000); // one second delay
PORTD = 2;
Delay_ms(1000); // one second delay
PORTD = 4;
Delay_ms(1000);
}
}

Now see the Video of our first project and see is it simulated or not.