Why led turning on when switch is low in pic starter kit

kitsledpicswitches

I have a PIC starter kit. I am doing a simple program of turning on led when switch is pressed and then turning them off when switch is released like following:

if(switch==1)
{
  led = 1;
}
else
{
  led = 0;
}

I was actually not able to do above code in MPLAB. Then I found a tutorial online. I used that code and it was working.

Switch is connected to RD7
Led is connected to RD0

CODE

if(PORTAbits.RD7 == 0) 
{
  PORTDbits.RD0 = 1;
}
else if(PORTAbits.RD7 == 1)
{
  PORTDbits.RD0 = 0;
}

Now I am confused. Why led is turning on when switch(RD7) is low. Can anyone explain me this logic.?

Best Answer

You should refer to the User Guide. It says that

Push button switches provide the following functionality:

• SW1: Active-low switch connected to RD6

• SW2: Active-low switch connected to RD7

• SW3: Active-low switch connected to RD13

also

The switches do not have any debounce circuitry and require the use of internal pull-up resistors; this allows you to investigate software debounce techniques.

So I think this answers your question of why led is turning on when switch(RD7) is low