Introduction: How to Blink an Led Using PIC Microcontroller ?

Picture of 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

Step 1: Components Required

Picture of Components Required

1) PIC16F886-1
2) 8Mhz crystal -1
3) 22pF capacitor -2
4) jumpers
5) Breadboard
6) 10K Resistor -2


7) Pic kit2 or pic kit3

Step 2: Circuit !

Picture of Circuit !

Connect the circuit on your breadboard as shown in diagram

Note: here MCLR is pin1

Step 3: Code

#define _XTAL_FREQ 8000000

#include

// 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)
//END CONFIG

int main()
{
TRISB0 = 0; //RB0 as Output PIN

while(1)
{
RB0 = 1;
__delay_ms(1000);
RB0 = 0;
__delay_ms(1000);
}

return 0;
}

Step 4: Install MPLab X Ide

Picture of Install MPLab X Ide

MPLab IDE is used to program PIC microcontrollers,Here IDE stands for Integrated development environment.


Download it from here ::

en.freedownloadmanager.org/Windows-PC/MPLAB-X-IDE-FREE.html


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 ::

www.microchip.com/mplab/compilers

Step 6: Steps to Write Programs on MPLab IDE

Picture of 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

Comments

About This Instructable

860views

9favorites

License:

Bio: Electronics and Automation Engineer, Game designer, Artist! EMAIL: amaraxr@gmail.com
More by AXR AMAR:#DIY# How to grow Bonsai (or any plant) using Internet of things (IOT)#DIY# A Complete Guide to Build Your own ATtiny85 Project PCB with Relay and Interfacing HC05 Bluetooth Module to it Pinguino Project (a PIC microcontroller based Arduino #No Programmer Required)
Add instructable to: