look to see if either button is pressed, then just simply drop down and test for both buttons active, then the left or right, running a timer to see if its a momentary or 2 second length. Of course if neither button is active, you can ignore the further testing. If you are not pin bound, but want a faster routine then you could externally OR the two buttons and just look for a single input to determine if either is active. And of course, you will want to debounce the inputs. It all depends on how fast you need to respond and how often you can poll. Using an interupt is easy as well...use the interupt on port B,0 to test for the OR condition. >From: "Mccauley, Daniel H" >Reply-To: pic microcontroller discussion list >To: PICLIST@MITVMA.MIT.EDU >Subject: [PIC]: IDEAS for Pushbutton Mode Selections >Date: Mon, 19 May 2003 11:00:43 -0400 > >Just wanted to get some ideas on what the most efficient way to do the >following is using a polled (non-interrupt) routine: > >In my main program loop, the user has two pushbuttons to control the >following modes > >1. Press and release LEFT button to run mode 1 >2. Press and hold LEFT button for 2 seconds to run mode 2 >3. Press and release RIGHT button to run mode 3 >4. Press and hold both LEFT and RIGHT buttons for 2 seconds to run mode 4. > >I realize there are a million ways to do this, but I need some ideas on how >to do this most efficiently. >Thanks > >D > >-- >http://www.piclist.com hint: The PICList is archived three different >ways. See http://www.piclist.com/#archives for details. _________________________________________________________________ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.