As written your code simply executes once and then does who knows what... You probably want for (;;) { if ( BTN1 =3D=3D 0 ) { PORT =3D ~PORT } } ----- Original Message -----=20 From: "Yigit Turgut" To: "Microcontroller discussion list - Public." Sent: Monday, October 24, 2011 12:01 PM Subject: [PIC] Pushbutton Trigger > Hi all, >=20 > /* > sbit BTN1 at RB1_bit; > sbit PROT at RB2_bit; > sbit TEST at RB3_bit; >=20 > void main() { >=20 > TRISB =3D 00001110; > PORTB =3D 00001010; > PROT =3D 0; >=20 > if( BTN1 =3D=3D 0){ > PROT =3D ~PROT } */ >=20 > BTN1 is active high and when pressed it shorts the pin to ground. But > when I run the test code above, PROT converts into its complement even > if the button is not pressed. Also when I type if(BTN1 !=3D 1) instead > of if(BTN1 =3D=3D 0), all logic levels are drawn to low, not responsive. > It's a very annoying thing, has anyone encountered such a behavior ? > --=20 > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .