You could shift until you get to a "1" bit, and use that one and ignore the rest. You could connect the switches to the PIC so that which ever one you came to first would have the highest priority. In other words, lets say we use PORTB and pushbutton #4 is the highest priority, 3 is the next highest, 2 the next and then 1. I would connect pushbutton 4 to PORTB,7, button 3 to PORTB,6, button 2 to PORTB, 5, and button 1 to PORTB,4. Now I shift left through carry, and the first "1" I come to is the button I process, and as a matter of course, I have also prioritized the buttons highest to lowest. From this you can choose where to branch to process that button. If no buttons are pressed, you go back and try it again. Or you could use interrupts. That way you could be doing something else while waiting for a button press. Regards, Jim ----- Original Message ----- From: "Rick" To: "'Microcontroller discussion list - Public.'" Sent: Thursday, March 26, 2009 6:01 PM Subject: [PIC] Input algorithm advise > Looking for advice on a way to insure that only one of four push buttons > is > active at one time. (IE - prevent multiple button press's) I have 4 > pushbuttons > on Port A (16F88) and have AND'ed these bits out. The only idea that I've > tossed > around so far is to rotate the bits and count them.. If count = 1 then > only one > push button is selected. Is there a better way to do this? > > Regards, > > Rick > > > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist