PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Dec 11, 2010 3:37 pm |
|
|
You could use the push-button code here:
http://www.ccsinfo.com/forum/viewtopic.php?t=23837
There is a sample program that shows how to call the button() routine.
Instead of the printf() statements, you could put in code to increment
or decrement a variable, based on which button was pushed. Make sure
you initialize the variable to some value at the beginning of the program.
Also put in code to check if the variable goes below or above some limit,
and prevent it from doing so (for safety).
This code expects the following circuit to be connected to your PIC pins
for each button. The circuit consists of a pull-up resistor and
a switch. Normally the pin is held at a logic "1" by the pull-up. When
you push the button it will go to a logic "0", until you release it:
Code: |
+5v
|
<
> 4.7K
< ___ Push button switch
To | _|_|_
PIC -----------------o o------
pin |
--- GND
-
|
If you have questions, ask them in this thread (not in the button.c thread). |
|