Summary of PIC16F877 LED blinking code and Proteus simulation
This article provides C code to make an LED blink using the PIC16F877 microcontroller, compiled with MPLAB and the HI-TECH C compiler. It explains the minimum circuit configuration needed, including a 20MHz crystal oscillator and a pulled-up MCLR pin to ensure proper operation. The RB0 pin is toggled in the code to turn the LED on and off. The project serves as an introductory step for beginners working with the PIC16F877. Code and Proteus simulation files are available for download.
Parts used in the PIC16F877 LED Blinking Project:
- PIC16F877 Microcontroller
- LED
- 20MHz Crystal Oscillator
- Resistor (for LED current limiting)
- MCLR Pin Pull-up Resistor
- Connecting Wires/Breadboard
This post provides the code to make an LED blink using PIC16F877 microcontroller. This code is written in C language using MPLAB with HI-TECH C compiler. This code is intended to be the first step in learning how to use PIC16F877 microcontroller in your projects. You can download this code from the ‘Downloads‘ section at the bottom of this page.
Following figure shows the minimum circuit required to make an LED blink with PIC16F877.
In this figure, first thing to note is that there is a crystal of 20MHz used with PIC16F877[1]. You can use any crystal from 0 to 20MHz with PIC16F877. MCLR master reset pin is pulled high to keep PIC16F877 out of reset. RB0 pin is being toggled in the code.
Code
The code for making LED blink using PIC16F877 is shown below.
Downloads
LED blinking code using PIC16F877 was compiled in MPLAB v8.85 with HI-TECH C v9.83 compiler and simulation was made in Proteus v7.10. To download code and Proteus simulation click here.
For more detail: PIC16F877 LED blinking code and Proteus simulation