Introduction: How to Blink an Led Using PIC Microcontroller ?
This tutorial is for PIC microcontroller beginners.
*steps to install MP Lab
*steps to install xc8 compiler
*program to Blink
*Building project and Burning it to the pic Mc
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Components Required
2) 8Mhz crystal -1
3) 22pF capacitor -2
6) 10K Resistor -2
7) Pic kit2 or pic kit3
Step 2: Circuit !
Connect the circuit on your breadboard as shown in diagram
Note: here MCLR is pin1
Step 3: Code
#define _XTAL_FREQ 8000000
// BEGIN CONFIG
#pragma config FOSC = HS // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = ON // Watchdog Timer Enable bit (WDT enabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
TRISB0 = 0; //RB0 as Output PIN
RB0 = 1;
RB0 = 0;
Step 4: Install MPLab X Ide
MPLab IDE is used to program PIC microcontrollers,Here IDE stands for Integrated development environment.
Download it from here ::
Step 5: Install Xc8 Compiler !
Xc8 compiler is used to compile the codes which are written in the MPLAB X IDE .
Download XC8 compiler from here ::
Step 6: Steps to Write Programs on MPLab IDE
Step 1 : open MPlabx click >file >new project
Step 2 : select standalone Project
Step 3 : select PIC16f886 (or your IC)
Step4: select your programmer in my case its pickit2 ,click next
Step5: select XC8 compiler
Step6: project name
Step7 : See the 7th Picture ..there select source files ,Right click >new>c main file !!
Step8 : Give name !
Step 9 : paste your program here !
Step10: Build main project
Step11: Run main project (or press F6)
Pickit will upload to your IC successfully !!
if any doubt please leave a message!!
Thank you !! :)
Step 7: Video of 3 LED Blinking
Participated in the
Automation Contest 2016