CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

A Push Button Algorithm Inquiry?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ritchie



Joined: 13 Sep 2003
Posts: 87

View user's profile Send private message

A Push Button Algorithm Inquiry?
PostPosted: Wed Feb 18, 2004 7:18 am     Reply with quote

Hello der!!!

Just a curiousity, What if I have a button-- when I press and hold it off course it will display a character corresponding to a keypress.

Is their an alogorithm when I press and hold the button it will only register one keypress for that specific button?

I need your comments, suggestions, sample snippets if any.

Thanx
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Wed Feb 18, 2004 7:54 am     Reply with quote

Do a search on debouncing.
Jeprox
Guest







PostPosted: Thu Feb 19, 2004 5:12 pm     Reply with quote

You don't mean debouncing, do you, because it's simply a matter of putting a delay or a few scans before finally reading it, with each scan doing a comparison with the previous read.

A simple approach (there are many ways of doing it) is to put a flag, declared as a short int, that will check if the button is pressed, and sets a flag.

short int flag= 0;
int value;


//assuming your push button is tied to Vcc through a resistor.

if((input(PUSH_BUTTON) != 1) && count==0)
{
printf("%d\r\n", value );
flag = 1;
}

if(input(PUSH_BUTTON))
flag = 0;
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group