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

Bit_test function

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



Joined: 05 Feb 2019
Posts: 5

View user's profile Send private message

Bit_test function
PostPosted: Wed Feb 27, 2019 3:20 am     Reply with quote

Hi, I'm using a PIC16F887 and want to check the state of a pin connected to a switch. So if a switch is pressed twice within a given time period a LED would light up. I have set up timer 0 to overflow after the needed time period but I'm not sure how to check if the switch is pressed twice in that time.

I have done some research and have read about the bit_test function that can be used to check the state of a pin but I don't completly understand how I could use it to check if the switch is pressed and then released twice. Can someone please help me with the code required?

Thank you
temtronic



Joined: 01 Jul 2010
Posts: 9253
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Feb 27, 2019 6:17 am     Reply with quote

couple of ideas.

1) download the 'button.c' driver from the code library!Written by PCM P. It's a GREAT piece of code giving you easy access to pushbuttons. As it's interrupt driven, your PIC can be doing other things. You read the 'button buffer' for new presses and then act upon those.

Currently I use it to look for a sequence of pushbutton presses within a timed limit. If the correct sequence is done an LED comes on.

just use the search optiob up top --> 'button.c' , choose 'code library' and it'll be found.

Jay
Mana



Joined: 05 Feb 2019
Posts: 5

View user's profile Send private message

PostPosted: Wed Feb 27, 2019 7:25 am     Reply with quote

Thank you I'll have a look Very Happy
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