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: 2008/11/22 01:57,
TOP NEW HELP FIND: 
38.103.63.58:LOG IN
©2008 PLEASE DON'T RIP! DO: LINK / DIGG! / MAKE!

 ©2008 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://www.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 reviewed) Just type in the box and press the Post button. (HTML welcomed!): 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: 
Did you find what you needed?

  PICList 2008 contributors:
o List host: MIT, Site host massmind.org, Top posters @20081122 Apptech, Jinx, Xiaofan Chen, olin piclist, Vitaliy, William \Chops\ Westfield, Tamas Rudnai, JonnyMac, Alan B. Pearce, Gerhard Fiedler,
* Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Shultz Electronics, Timothy Weber, on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
  'What can I do?' - SiCKO

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .