-----Original Message----- From: Randie Ohtsji [4555] To: PICLIST@MITVMA.MIT.EDU Date: Thursday, 16 October 1997 14:42 Subject: What is the best way to sense a pushbutton press??? >Hello, > >What is the best way to sense a push button press? I am multiplexing the >PORTB data lines as a data bus and using PORTA as chip select as shown >to me by Steve Smith. Will the below circuit work? > >An HC74 D Flip-Flop is used to capture a push button press since inputs >will only be scanned briefly and I don't want to miss the press. > >The inputs are selected by selecting RD1 and storing to a register. >If PB0 reads as set then I know that the button was pressed. I then >reset the F/F by selecting WR1 and tickling PB7. > >Is there a better way to achieve this??? I need to multiplex the pins >since there are many inputs and outputs (LCD display, ISD voice chip etc) Use the B lines(1) in interrupt mode, with the soft pullups (downs?) enabled. If you've got an array of switches to multiplex, try and arrange them in a regular shape. the other side of the switch goes to some more pins(2), that are set to the opposite sense. When any button is pushed, it will trigger an interrupt. In the ISR, you clear lines(2), and then set one at a time, reading the lines(1) to find out which switch caused it. Some debounce is necessary. Sorry about the awkward description - haven't a data source nearby!!