Setting the configuration bits
Macro for setting configuration bits must be placed somewhere at the top of the source file, right after the #include lines. For portability sake, I recommend this method rather than setting them in IDE.
Regardless of which clock source you will be using afterwards, the system is configured to use FRC at startup.
Next, use this macro for FRC case
_FOSC(FCKSM_CSECMD & OSCIOFNC_ON & POSCMD_NONE);
and for the external crystal case
_FOSC(FCKSM_CSECMD & OSCIOFNC_OFF & POSCMD_XT);
The latter is used for both cases in Microchip document. Consult the PIC24EPdatasheet and family reference manual for the meaning of each definition.
I/O Port Definitions
As shown in figure 1 above, only one input port (RB2) is used for the push-button switch, and one output port (RB15) for LED. Define them accordingly
#define SW1 !_RB2 // switch is active-low
#define LEDB _LATB15 // blue LED
Then put these lines in main() before the infinite loop, or in an init( ) function called by main.
ANSELA=0x0000; // use all ports RA and RB as digital
_TRISB2 = 1; // RB2 as input
_CNPUB2 = 1; // enable internal weak pull up
_TRISB15 = 0; // RB15 as output