int main ()
{
//switch configuration
//select the direction register of port k :0x107
//make the directio register of port k as input by 0x00
//select the input port address of portk :0x106
//Imp for switch or mechanical button//
//pull down of pin
//take care of masking
//debouncing
volatile char *dir_k , *input_port_k , x ;
volatile long t;
dir_k = 0x107;
*dir_k = 0x00;
input_port_k = 0x106;
//LED configuration
//select the direction register of portf :0x30
//make the directio register of port f as output by 0xff
//select the output port adress of portf :0x31
volatile char *dir_f, *out_f;
dir_f = 0x30;
*dir_f =0x01;
out_f = 0x31;
//if switch is pressd the led should glow
while(1)
{
//read the value of switch
x = *input_port_k;
//if Switch is pressed at portk the LED at port f should glow
//i.e if *input_port_k gets HIGH value LED should Glow
if((x & 0x01) == 0x01) //here masking is done
{
for(t = 0 ; t<5000 ; t++);//debounce time to give time to output of swith
*out_f = 0x03; // to get stable
}
else
*out_f = 0x00;
}
return 0;
}