Hello, today I will do very simple project using PIC16F877. This is a basic project for begginer.
PIC16F877 is a very popular microcontroller. Those who are new with PIC micro controller, this project will demonstrate that how to make a specific pin of a port make high or low. PIC16f877 micro controller has 5 port. These are PORT A, PORTB, PORTC, PORTD and PORTE. Each port has some specific purpose. May be in other post we will discuss about this. To do this we need following software:
1. MikroC pro for PIC (student verison)
2. Proteus 8 professional
3. PicKit 2
MikroC pro for PIC will be used for writing and compiling the code. Here we will use C language.
Proteus 8 professional will be used for the simulation and finally Pickit 2 will be used for burning the hex file in the PIC16F887 IC.
To do this project we need following components;
1. PIC16F877
2. LED
3. 16 MHz Crystal Oscillator
4. Breadboard
5. Wires
6. 5V DC Power source
In the following figure we have the pinout of PIC16F877
In the following figure we have the pinout of PIC16F877
Figure 1
MikroC Code:
// LED Flashing
void main()
{
TRISB = 0;
PORTB = 0;
ADCON1= 0x06;
while(1)
{
PORTB = 0b00000001;
delay_ms(200);
PORTB = 0b00000000;
delay_ms(200);
PORTB = 0b00000010;
delay_ms(200);
PORTB = 0b00000000;
delay_ms(200);
PORTB = 0b00000100;
delay_ms(200);
PORTB = 0b00000000;
delay_ms(200);
PORTB = 0b00001000;
delay_ms(200);
PORTB = 0b00000000;
delay_ms(200);
PORTB = 0b00010000;
delay_ms(200);
PORTB = 0b00000000;
delay_ms(200);
PORTB = 0b00100000;
delay_ms(200);
PORTB = 0b00000000;
delay_ms(200);
PORTB = 0b01000000;
delay_ms(200);
PORTB = 0b00000000;
delay_ms(200);
PORTB = 0b10000000;
delay_ms(200);
PORTB = 0b00000000;
delay_ms(200);
PORTB = 0b10101010;
delay_ms(1000);
PORTB = 0b00000000;
delay_ms(500);
PORTB = 0b01010101;
delay_ms(1000);
PORTB = 0b00000000;
delay_ms(500);
PORTB = 0b11111111;
delay_ms(1000);
PORTB = 0b00000000;
delay_ms(500);
}
}
Diagram
Figure 2
Please don't forget to connect pin 1,11 and 32 to 5V source.
Connect pin 12 and 31 with Gnd. Also connect 16 MHz oscillator with pin 13 and 14.
THANKS A LOT.
No comments:
Post a Comment