Thanks guys, Most of my frustration is now gone after realizing that at some point I must have deleted the line that selected bank 0 after setting tris in bank 1. Bit tests are now reporting as expected. Why the ^%&^%*^%(&%% doesnt the assembler catch this? It has those annoying messages about specifying a bit in bank 1. Oh well it is free. We you are a newbie like me it is very easy to completely blow the mind and requestion everything that you think you understand. -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Jinx Sent: Tuesday, May 21, 2002 4:05 PM To: PICLIST@MITVMA.MIT.EDU Subject: Re: [PIC] - Detecting the press of a button (after carefully checking there's no SPDT in sight) > Can someone please give me a small checklist of what > it takes to detect the press of a button? Include setup of > port, pullup conditions,wiring, bit testing, etc. Bank1 - set trisb bit4 to 1 for input Test PortB,4 in Bank0 - even banks are port, odd banks are tris Pulldown to Vss, pushbutton to Vcc or pullup to Vcc, pushbutton to Vss Wires as short as possible, add a buffer/driver for over, say, 1m but that may depend on the value of the resistor, quality of wire, environmental noise etc. Adding an RC network will help filter any noise from the pushbutton. Put a high (compared to the R, eg R=10k, discharge=100k) value resistor across the C to discharge it after the push- button is released > btfsc PORTB,4 > call rb4on > return should be OK for checking the default state if using a pulldown With a pullup and grounded pushbutton you'd change the test for default to btfss If you've just the one pushbutton you might consider RB0/INT -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu