PIC16F84A LED blinking code and Proteus simulation

Summary of PIC16F84A LED blinking code and Proteus simulation


This article explains how to make an LED blink using the PIC16F84A microcontroller, with code written in C language using MPLAB and the HI-TECH C compiler. It includes a basic circuit involving a 20MHz crystal and details on configuring the microcontroller, such as pulling the MCLR pin high and toggling the RA0 pin. The article also provides downloadable resources, including the source code and a Proteus simulation for practical implementation and learning.

Parts used in the PIC16F84A LED Blinking Project:

  • PIC16F84A microcontroller
  • 20MHz crystal oscillator
  • LED
  • Resistor (for LED current limiting)
  • MCLR pull-up resistor
  • Power supply (5V typical)
  • Connecting wires and breadboard/circuit board

This post provides the code to make an LED blink using PIC16F84A 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 PIC16F84A microcontroller in your projects. You can download this code from the ‘Downloads‘ section at the bottom of this page.

PIC16F84A LED blinking

Following figure shows the minimum circuit required to make an LED blink with PIC16F84A.

In this figure, first thing to note is that there is a crystal of 20MHz used with PIC16F84A[1]. You can use any crystal from 0 to 20MHz with PIC16F84A. MCLR master reset pin is pulled high to keep PIC16F84A out of reset. RA0 pin is being toggled in the code.

Code

The code for making LED blink using PIC16F84A is shown below.

Whenever you are writing code for PIC microcontrollers, then you have to include “htc.h” file in the code. After including “htc.h” file, configuration bits are being set in the code shown above. To understand the details of how these configuration bits are being programmed, you can read this post.

PIC16F84A LED blinking schematic

Downloads

LED blinking code using PIC16F84A 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: PIC16F84A LED blinking code and Proteus simulation

 


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.