PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 04, 2007 12:16 pm |
|
|
To me, it just sounds like you're making more complicated then it
needs to be. I made the following test program for a PicDem2-Plus
and it displays an incrementing number as I press the tactile switch
that's connected to Pin B0. Here's the output displayed on a terminal
window:
Code: |
#include <18F452.h>
#fuses XT, NOWDT, PUT, BROWNOUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#define BUTTON_PIN PIN_B0 // This pin must have a pull-up.
#define DEBOUNCE_PERIOD_IN_MS 10
#define DEBOUNCE_COUNT 2
void wait_for_keypress(void);
//====================================
void main()
{
int value;
value = 0;
while(1)
{
wait_for_keypress();
value++;
if(value == 1)
printf("1");
if(value == 2)
printf("2");
if(value == 3)
{
printf("3");
value = 0;
}
}
while(1);
}
//==================================
void wait_for_keypress(void)
{
// Put the function code here from the link that
// I posted earlier in the thread.
}
|
|
|