LED Blinking with PIC Microcontroller

In: Project Code: ES000004
Advertisements
Share

Execute this project and learn how to blink led connected to the GPIO pins of PIC16F877A microcontroller using MPLAB IDE and PICKIT programmer.

course thumb

Project Content


Required hardware and software


The required hardware and software for this project is as below:

  • A breadboard
  • 1 x 4mmLED
  • 1 x resistor between 220 Ohm to 1 kOhm
  • Hookup cables
  • Development board hosting PIC16F877A 8-bit microcontroller
  • MPLAB IDE from Microchip
  • PICKIT3 Programmer, connecting cable from PICKIT3 to your computer.
  • Development board hosting PIC16F877A Microcontroller
  • Power supply for the development board
  • The hardware components required for the project, their concepts and theory of operation are explained below:
    A light-emitting diode (LED) is a two-lead semiconductor light source. It is a p–n junction diode that emits light when activated. When a suitable current is applied to the leads, electrons are able to recombine with electron holes within the device, releasing energy in the form of photons. Light-emitting diodes are used in applications as diverse as aviation lighting, automotive headlamps, advertising, general lighting, traffic signals, camera flashes, lighted wallpaper and medical devices.

    The hardware components for the project are shown in the following picture. I am using ETK01001 embedded trainer kit board for this project where I am connecting a hookup cable from microcontroller GPIO pin to a led on the board.

    Required Components
  • Light emitting diode(LED) has +ve and -ve polarity. The long lead of led is +ve and short lead of led is -ve.
  • The resistor has no polarity. So you can connect it in any direction

  • Schematic diagram


    The schematic diagram for this project is as shown below:

    Required Components

    PIC16f877A GPIO description


    PIC16F877A is a 8-bit microcontroller. Download the datasheet of the microcontroller here.

    Once you have everything set up it should look something like this:


    Building the software program, creating binaries


    Before starting on software development, let me introduce you some basic stuff on programming. To solve a problem you are creating a project/product. You need to develop source code for the project. To edit source code you need an editor or IDE. You need a compiler to compile your source code. We will use MPLAB X IDE for this project which is an IDE meaning XC8 compiler is integrated into it.

    Follow the below steps to edit source code, compile source code, create binary for your project:
  • Download MPLAB X IDE 5.05 from here and install in your computer.
  • Create a project, click on file->New Project. Choose project as standalone project. Click Next >.
  • Select device as Baseline 8-bit MCUs and device as PIC16F877A. Click Next >
  • Select Tool as PicKit3. Click Next >
  • Select compiler as XC8. Click Next >
  • Provide a project name and folder to store it in your computer. Click Finish
  • On the MPLAB IDE Projects window you will see the project created. I have named the project as led. Right click on the Source Files under led and click on New->C Source file. Give the name of file as led.c and click on Finish.
  • Double click on the led.c file under Source Files and enter the following code in it.
  • Click on Build Main Project button with hammer icon and you will see Build Successful on the output window of MPLAB IDE.

  • To Read Full Article

    Login or Register to create a free Mbed Technologies account

    Register Login
    Looking for a new project? Write and upload your project information .
    Share

    Articles


    C Programming

    More Articles Categories

    Technical articles

    Prepare for software jobs


    Test your skills