I'm making a program for the msp430.
The incrementation runs away on first button click. It doesn't stop when the button is released.
How can incrementation be limited to one incrementation for each button click?
#include <msp430.h>
int main(void)
{
int i; //delay variable
int dimeRead=0;
int desired=1000;
volatile int total=0;
P1OUT=0; //Supposed to get rid of it hanging at the top
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
while(total<desired)
{
if((P1IN&0x16)!=0x16) // check if switch is pressed or not
{
dimeRead=dimeRead+1;
total=total + 10;
}
//Goal is to flip an out put on to turn on light when desired number is hit.
}
return 0;
}
0x16
....I guess you need0x08
or something like that. I mean that 0x16 is binary10110
and you probably want to test a single bit. With0x08
you can check bit 3 only, for example - LPs#define mask (1<<4) // pin 4
. - Lundinreturn 0;
- Where do you return to?? There is no shell/etc. to return to. - too honest for this site