Quote Originally Posted by xobx View Post
If I make the code like tis:

Code:
@   device  pic16F648A, hs_osc, wdt_off, mclr_on, lvp_off, protect_off
DEFINE OSC 20

LED1 var PORTB.1
PRESS var PORTA.1
CMCON=7


loop:

If press=0 then       
            high led1  
            else
            low led1  
            endif      
            goto loop   
            end
Should it be like this?

No. The first way is what you want. When the switch is open the pin is "0"LOW. When the switch is closed the pin is "1"HIGH.

If you are using push buttons, you will need to use either a normally open "NO" or a normally closed "NC".

The resistor keeps the pin LOW (no float). High resistance is used to minimize the current through the switch (just a little short).

Depending on how you look at it this is called a pull up or a pull down.