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?
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.
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