//(c)Shane Tolmie, http://www.microchipc.com/, distribute freely for non commercial use on the condition that you include this web link somewhere in your document.
#include <pic.h> //designed for PIC16F877
#include <htc.h>
__CONFIG ( FOSC_HS & WDTE_OFF & PWRTE_OFF & CP_OFF & BOREN_OFF & LVP_OFF & CPD_OFF & WRT_OFF & DEBUG_OFF );
#define _XTAL_FREQ 20000000L // Used in __delay_ms() functions
#define OUTPUT 0
#define INPUT 1
main()
{
TRISB1=OUTPUT; // change port RB1 direction to output
TRISB2=OUTPUT; // change port RB2 direction to output
while(1)
{
RB1=1; // produce 5V on RB1, pin 34 of micro
RB2=0; // produce [U]0[/U]V on RB2, pin 35 of micro
__delay_ms(500); // delay 500ms
RB1=0; // produce 0V on RB1, pin 34 of micro
RB2=1; // produce [U]5[/U]V on RB2, pin 35 of micro
__delay_ms(500); // delay 500ms
}
}