Blink an LED using PIC16F84A and CCS PIC C compiler
This topic shows a simple example for making an LED blinks using Microchip PIC16F84A 8-bit microcontroller and CCS PIC C compiler. It is easy to make an LED blinking, a few program lines are required and the microcontroller PIC16F84A is a simple chip also.
LED: Light Emitting Diode
Hardware Required:
- PIC16F84A microcontroller —> datasheet
- LED
- 8 MHz crystal oscillator
- 2 x 22 pF ceramic capacitor
- 10k Ohm resistor
- 330 ohm resistor
- Breadboard
- 5V source
- PIC Microcontroller programmer (PICkit 3, PICkit 4…)
PIC16F84A LED blink example circuit:
Circuit schematic diagram for the LED flasher is shown below.
In this example the PIC16F84A microcontroller runs with 8 MHz crystal oscillator, the LED is connected to pin RA0 through a current limiting resistor of 330 Ohm.
MCLR pin (#4) of the PIC16F84A microcontroller is connected to circuit VCC (+5V) through 10k Ohm resistor.
PIC16F84A LED blink example C code:
Code is written with CCS compiler, it was tested with version 5.051.
The C code is described through comments.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | // PIC16F84A LED blink example // http://simple-circuit.com/ #include <16F84A.h> #use delay(crystal=8000000) void main(){ while(TRUE){ // Endless loop output_low(PIN_A0); // LED OFF delay_ms(500); // Delay 500 ms output_high(PIN_A0); // LED ON delay_ms(500); // Delay 500 ms } } |
PIC16F84A LED blink example simulation video:
The following video shows the simulation of this project using Proteus simulation software.
Related Project:
PIC16F84A LED blink using push button – CCS C compiler