You are on page 1of 3

LED ON AND OFF USING PIC16F877A

INTRODUCTION:
In this lab,
 we will first write the code on mikroC pro ,
 compile on it and
 then we will use the hex file of this code for simulation in proteas by uploading
the hex file in proteas and
 by burning code in microcontroller.

MIKROC PRO:
First of all, write a code for led that will turn led on and off on pressing of the button.
The code is:

void main()

TRISA=0xff;

TRISC=0x00;

while(1)

if(PORTA=1)

PORTC=1;

else

PORTC=0;

}
After we save this code, a hex file will be generated which will be used for proteus as
well as for burning the code in the micro controller.

PROTEUS:
Now we will simulate the program using the hex file of mikroc pro.
First draw the diagram as following and then double click on the MCU and add hex file
so that we can simulate.

Now run the simulation on proteus.


BURN CODE IN MCU:
For code to burn in the MCU, we use software name PIckit2.
Attach the pickit2 with the computer and attach MCU with the kit and then open the
software from the computer and click on write and import option from software in order
to burn code using hex file.

HARDWARE IMPLEMENTATION:
This part has been successfully done and it was shown to our instructor that the LED
was turning on and off.

CONCLUSSION
Basically, the purpose of this lab was to make students aware that the simple job of
turning led on and off can also be done using microcontroller and to get our basic right
as far as pic16f877a is concerned.

You might also like