please dont rip this site

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);
	}
}

Interested:


file: /techref/microchip/language/c/debounce-dh.htm, 1KB, , updated: 2007/9/14 16:52, local time: 2009/11/21 19:23,
TOP NEW HELP FIND: 
38.107.191.104:LOG IN
©2009 PLEASE DON'T RIP! DO: LINK / DIGG! / MAKE!

 ©2009 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it!
<A HREF="http://piclist.com/techref/microchip/language/c/debounce-dh.htm"> Microchip PIC, keyswitch, switches, debounce, CCS C compiler, Damon Hopkins</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 
The PICList mailing list is hosted by MIT and we GRATEFULLY ACKNOWLEDGE the huge bandwidth and server load they sholder for us. If you want this list to continue, please consider contributing to MIT... Every little bit helps them educate the worlds finest minds and justify their expense in running the PICList mailing list.
  'What can I do?' - SiCKO

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .