hi,
Do you have the datasheet for your PIC?. if not download it from
www.microchip.com
If look at the pin designations on the datasheet, you will see some pins are multi-function and have to be configured
to perform the function of your choice.
A quick look at pin#4, shows it as either RA5, MCLR [or Vpp], the configuration word CONFIG at the near the top of your program code sets the function of RA5.
Bit #5 of the Config word reg, if set high makes pin#4 the MCLR, if low it a inp/out pin RA5.
IIRC in your code Config bit#5 is ON [hi] which makes the RA5 pin MCLR.
Looking at your diagram, pin #4 goes to a connector and dosn't show any pullup to +Vdd. [
unless its somewhere else off board??]
Your code runs OK in my sim, which it would do, even if MCLR was not connected, thats one of the shortcomings of simulators.
Ref: your 9Vbty, from what you say, you need a new battery.
Does this help?
This is your config word:
__CONFIG _BODEN_ON & _CP_OFF & _DATA_CP_OFF & _PWRTE_ON & _WDT_OFF & _LVP_OFF & _
MCLRE_ON & _INTRC_OSC_NOCLKOUT