the code is as following already, forgot to add sorry; sbit BTN1 at RB1_bit; sbit PROT at RB2_bit; sbit TEST at RB3_bit; void main() { TRISB =3D 00001110; PORTB =3D 00001010; PROT =3D 0; while(1){ if( BTN1 =3D=3D 0){ PROT =3D ~PROT } } On Mon, Oct 24, 2011 at 7:17 PM, Bob Ammerman wrote= : > As written your code simply executes once and then does who knows what... > > You probably want > > for (;;) > { > =A0 =A0if ( BTN1 =3D=3D 0 ) > =A0 =A0{ > =A0 =A0 =A0 =A0PORT =3D ~PORT > =A0 =A0} > } > > ----- Original Message ----- > From: "Yigit Turgut" > To: "Microcontroller discussion list - Public." > Sent: Monday, October 24, 2011 12:01 PM > Subject: [PIC] Pushbutton Trigger > > >> Hi all, >> >> /* >> sbit BTN1 at RB1_bit; >> sbit PROT at RB2_bit; >> sbit =A0TEST at RB3_bit; >> >> void main() { >> >> TRISB =3D =A000001110; >> PORTB =3D 00001010; >> PROT =3D 0; >> >> if( BTN1 =3D=3D =A00){ >> PROT =3D ~PROT } */ >> >> 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 ? >> -- >> http://www.piclist.com PIC/SX FAQ & list archive >> View/change your membership options at >> http://mailman.mit.edu/mailman/listinfo/piclist > -- > 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 .