LED Blinking with PIC Microcontroller

In: Project Code: PE000004

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

The setup requirement for this project is as given below:

course thumb

Project Content

Online courses related to this project

Course description

Learn firmware development theory, applications, get practical skills from online tests, projects and earn certificate for software jobs

Course description

Learn to develop embedded systems, interfacing electronic peripherals through real time projects and get required practical skills for software jobs

Required hardware and software

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

  • A breadboard
  • 1 x 4mm LED
  • 1 x resistor between 220 Ohm to 1 kOhm
  • Hookup cables
  • MPLAB IDE from Microchip
  • PICKIT3 Programmer, connecting cable from PICKIT3 to your computer
  • Development board hosting PIC16F877A Microcontroller
  • Power supply for the development board
  • 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.

  • 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
  • I am using our company for this project. You can use any PIC development board for this project. You can also and execute the project remotely from anywhere.

    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 . It has total 40 pins out of which 33 pins are used for GPIO. PIC16F877A has 5 ports namely PORTA, PORTB, PORTC, PORTD, PORTE. The GPIO pins are used interfacing different input/output devices to the PIC microcontroller.

    PORTA - PORTE registers in PIC16F877A microcontroller have alternate functions which means when a pin in the register is used for alternate function it cannot be used for general purpose input/output functions. This is determined by the internal register settings configured by the user program. So to use as a led control pin we need to configure the pin connected to the led as GPIO output.

    GPIO Registers

    Register Register Description
    TRISX Determines whether the PORT or pin is used for input or output. If TRISX bit=1, the corresponding port pin is set as input. If TRISX bit=0, the corresponding port pin is set as output.
    PORTX The actual data that will be written on the PORT or pin.

    The PORTA - PORTE registers, their pins and alternate functions are defined in the following table.

    PORTA - PORTE Registers, pins, alternate functions

    Register Pins Alternate functions
    PORTA PA0 - PA5 Analog to Digital Converter(ADC).
    PORTB PB0 - PB7 Interrupts.
    PORTD PD0 - PD7 Parallel slave port.
    PORTE PE0 - PE2 Analog to digital converter(ADC).

    Building the software program, creating binaries

    To Read Full Article

    Start any course from the following
    Looking for a new project? Write and upload your project information .