#include <htc.h>
#include <18f1230.h>
#include <delay.h>
#define XTAL_FREQ 4MHZ //crystal FREQ
//***************************************Configuration Fuses
__CONFIG(1, HS);
__CONFIG(2, WDTDIS);
__CONFIG(3, MCLRDIS);
__CONFIG(5, UNPROTECT);
//******************************************************Main
void main(){
unsigned short old_u;
ADCON1 = 0b00001111;
CMCON = 0b00000111;
TRISB = 0b00010000;
PORTB = 0x00;
while(1){
if(RB4){
RB1 = 1;
old_u = 1;
}
if(old_u && (!RB4)){
RB1 = 0;
old_u = 0;
}
}
}