Jump to content
Sign in to follow this  
mchristisen

While And If Statement Question

Recommended Posts

still new to programming and cant figure this one out.

 

why with the following code does it take two buttonfour presses

to get out of the while statement? To me it should only take one

press.

 

i=1;
while(i==1)
	{
		if (ButtonFour == 1)
			{
				while (ButtonFour == 1);
				i=0;
			}
		if (ButtonOne == 1)
			{
				while (ButtonOne == 1);
				TEACHONE();
			}
	}

 

 

matt

Share this post


Link to post
Share on other sites

It depends on the type of keypad, how noisy the button presses are,

or just simply a crude debounce/verification method.

 

There are many more efficient ways to debouce noisy buttons, etc

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...