PIC16F877A LED blink

The Microchip PIC16F877A has 40 pins 33 of them can be input or output. In this simple project I am going to configure this microcontroller to blink a 33 LED each LED is connected to one I/O pin.
PIC16F877A LED blink
The PIC16F877A has 8 analog channels, so we have to configure all these channels as digital output.
The pin RA4 is an open drain output we must add a pull up resistor to turn it on and off.
The circuit schematic is shown by the following picture:
The code is written using MikroC PRO for PIC compiler:
Β PIC16F877A LED blink Schematic
voidΒ main(){ Β ADCON1Β =Β 0x07;Β Β Β Β Β Β Β Β Β Β //Β ConfigureΒ allΒ analogeΒ pinsΒ asΒ digital Β PORTAΒ =Β 0;Β TRISAΒ =Β 0;Β Β Β //Β ConfigureΒ PORTAΒ asΒ output Β PORTBΒ =Β 0;Β TRISBΒ =Β 0;Β Β Β //Β ConfigureΒ PORTBΒ asΒ output Β PORTCΒ =Β 0;Β TRISCΒ =Β 0;Β Β Β //Β ConfigureΒ PORTCΒ asΒ output Β PORTDΒ =Β 0;Β TRISDΒ =Β 0;Β Β Β //Β ConfigureΒ PORTDΒ asΒ output
Β  PORTEΒ =Β 0;Β TRISEΒ =Β 0;Β Β Β //Β ConfigureΒ PORTEΒ asΒ output Β whileΒ (1)Β {Β  PORTAΒ =Β ~Β PORTA;Β Β Β Β Β Β Β //Β InvertΒ PORTAΒ status Β Β PORTBΒ =Β ~Β PORTB;Β Β Β Β Β Β Β //Β InvertΒ PORTBΒ status Β Β PORTCΒ =Β ~Β PORTC;Β Β Β Β Β Β Β //Β InvertΒ PORTCΒ status Β Β PORTDΒ =Β ~Β PORTD;Β Β Β Β Β Β Β //Β InvertΒ PORTDΒ status Β Β PORTEΒ =Β ~Β PORTE;Β Β Β Β Β Β Β //Β InvertΒ PORTEΒ status Β Β delay_ms(500); Β Β } }

For more detail: PIC16F877A LED blink


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.