Toll-Free Customer Support 24/7

PIC Development Board

/*
* Project name:
PIC Development Board
* Copyright
(c) Researchdesignlab.com
* Test configuration:
MCU: PIC16F877A
Dev.Board: PIC
Oscillator: 20.0 MHz
Software: MPLAB IDE v8.92(HI-TECH_C)
*/


/*LED Blinking using pic controller(16F877A) using MPLAB*/

 

#include <htc.h>
#define _XTAL_FREQ 20000000 //crystal frequency of 20MHZ

#define Input1 RB7 //Input port
#define Input2 RB1 //Input port
#define Output1 RB4 //output port
#define Output2 RB5 //output port

void main()
{
TRISB=0X82; //using portB register as input as well as output


while(1)
{
if(Input1==0) //if switch1 is pressed
{

Output1=1; //blink both the LED’S
Output2=1;

}
else if(Input2==0) //If switch2 is pressed
{
Output1=0; //both the LED’S should turn off
Output2=0;

}
}
}

Back to top