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:
Learn to develop embedded systems, interfacing electronic peripherals through real time projects and get required practical skills for software jobs
The required hardware and software for this project is as 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.
I am using our company ETK01001 embedded trainer kit board for this project. You can use any PIC development board for this project. You can also schedule this project on our company hardware and execute the project remotely from anywhere.
The schematic diagram for this project is as shown below:
PIC16F877A is a 8-bit microcontroller. Download the datasheet of the microcontroller here. 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.
|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||PA0 - PA5||Analog to Digital Converter(ADC).|
|PORTB||PB0 - PB7||Interrupts.|
|PORTC||PC0 - PC7||PWM, UART, I2C.|
|PORTD||PD0 - PD7||Parallel slave port.|
|PORTE||PE0 - PE2||Analog to digital converter(ADC).|