PIC Micro Controller C Input / Output Routine

CCS code for button pressing debouncing

by Damon Hopkins

you can fiddle with the delay I have it count for 50 ms in between reads and then when it counts 5 button presses it returns

// wait_for_release(PORTA,0)
void wait_for_release(char port, short pin)
{
	char x=0;
	while(x != 5)
	{
		if (!bit_test(port,pin))
			x++;
		else
			x=0;
		delay_ms(50);
	}

}
// wait_for_press(PORTA,0)
void wait_for_press(char port, short pin)
{
	char x=0;
	while (x!=5)
	{
		if (!bit_test(port,pin))
			x=0;
		else
			x++;
 		delay_ms(50);
	}
}

Questions:

Interested: