On Wednesday 11 Jun 2003 12:06, you wrote: > It's easier to read and more informative to use includes and an > itemised CONFIG statement > Now that I understand how to write to a port I thought that reading from a port would be just as easy, but it seems it's not. This code is based on that provided by Jinx but I seem to be missing something. The LED is always on no matter what the state of pin 18. Could someone put me on the right track? PROCESSOR p16f628 INCLUDE p16f628.inc __CONFIG _CP_OFF &_WDT_OFF &_BODEN_OFF &_PWRTE_ON &_INTRC_OSC_NOCLKOUT ERRORLEVEL -302 ; Don't care about the "bank bits" messages ;****Set up the port**** bsf STATUS,5 ;Switch to Bank 1 movlw b'00000010' ;Port A1 input the rest outputs movwf TRISA ;to output. movlw 07h ;set Port A1 movwf CMCON ;to digital mode bcf STATUS,5 ;Switch back to Bank 0 clrf PORTA ;****Turn the LED on if pin 18 is grounded**** Start btfsc PORTA, 1 ;wait for a.1 to ground goto Start movlw 04h ;Turn on the LED movwf PORTA goto Start end -- Regards, Phil. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu