i need to make somekind of "on-off" button with my project. when the button not pressed, it supposed to print
stopped
if pressed
started
the problem is, when im not pressin it, it keep printin 'stopped', same when i keep pushin the button. i want it to only print the data once. more detail, what i need is, the button hold the stay in 'STARTED' position until i press it again.
here is my code
{
int main (void)
int TestM4;
while(1)
{
if (!(PORTJ_IN&PIN1_bm)) //test m4
{
testM4 = 1;
printf("%d\n", testM4);
}
else
{
testM4 = 0;
printf("%d\n", testM4);
}