In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Sparks-R-Fun wrote: I took a quick but not thorough look at your code. Two things stand out. The first is that SetHrs and SetMins are nearly identical in function. With a little rewriting you could probably use a single function to update all of your time settings. I think something like TimeDate(Setting) = ChangeSettingFunction, MaxValue should work quite well for your application. My second observation deals directly with the question you raised regarding the quick exit from your second subroutine call. What I think is happening is that when you press the exit button the first subroutine exits immediately and the second subroutine is called while the button is still pressed. The second subroutine should make one pass through your DO LOOP before checking the exit condition. This likely occurs much faster than you could possibly release the button so it exists after only a single pass. A quick (I have not given much thought to whether or not it is the best) solution would be place a conditional loop to look for the opposite condition between the two subroutine calls (or at the end of the change settings subroutine if you chose to combine them). Basically you need to look for the '0' button to be released before you enter another subroutine that will also be expected to terminate as soon as it sees the '0' button is pressed. You should be aware that if your push buttons are not electrically debounced it is entirely possible that your software could see hundreds of electrical transitions for a single press of the button. If that is the case, you will need to "debounce" the buttons in software. A quick fix might take the following form, though I am sure there are other ways to accomplish the same result. [CODE] WaitForZeroButtonRelease Sub 0,0 . . . SetHrs WaitForZeroButtonRelease SetMins . . . WaitForZeroButtonRelease: PAUSE 500 ' Pause 500 milliseconds to allow the button to reach a stable state. DO WHILE switches.0 = 1 ' Loop while the switch is pressed. LOOP ' keep looping until the switch is released. RETURN[/CODE] I hope this helps. - Sparks ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=191734#m191799 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)