This is a multi-part message in MIME format. --------------59C1114C642919AC129189E1 Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by ns1.ptt.yu id fBJDxtK11610 Hello! I am going to build a simple PIC controlled electronics for opening gate on garage. Using PIC16F84 @4MHZ Idea is that: With IR TV remote control i am sending impulses to SFH506, he send impulses to PIC, he will start first relay for opening - this relay starting one contactor, which now will hold it self until gate is opened Also, when i want to close, again i am sending impulses, but now second relay will act. I am using (as outs) simple NPN transistor which drive small 12V relay with only R in base - no PulUp or PullDown Problem is that when i start PIC, he start to open-close respectively first ans second relay.... What is problem?? THANKS! p.s. I am using PBP compiler '***DEFINITION OF I/O PORTS TRISB.0=3D1 ' PORTB0 je input TRISB.4=3D0 ' PORTB4 je output TRISB.5=3D0 ' PORTB5 je output '***DEFINI=D2ION OF VARIABLES GATE_IS_UP VAR BYTE ' Show us that gate is up GATE_IS_DOWN VAR BYTE ' Show us that gate is down SENZOR VAR PORTB.0 ' Define PORTB0 as SENZOR RELAY_OPEN VAR PORTB.4 ' Define PORTB4 - relay for opening UP RELAY_CLOSE VAR PORTB.5 ' Define PORTB5 - relay for closing DOWN '***MAIN PROGRAM FIRST_CONDITION: PauseUs 35 IF SENZOR =3D 0 Then ' If there is 0 on senzor GoTo SECOND_CONDITION: ' Go on Second_condition Else GoTo FIRST_CONDITION EndIF SECOND_CONDITION: PauseUs 35 ' Wait for impulses IF SENZOR =3D 1 Then ' If there is 1 on senzor GoTo THIRD_CONDITION Else GoTo FIRST_CONDITION EndIF THIRD_CONDITION: PauseUs 35 IF SENZOR =3D 0 Then GoTo GATE_DOWN Else GoTo FIRST_CONDITION EndIF GATE_DOWN: IF Gate_Is_Down =3D 1 TheN GoTo GATE_UP Else RELAY_CLOSE =3D 1 Pause 1500 RELAY_CLOSE =3D 0 Pause 1000 Gate_Is_Down =3D 1 Gate_Is_Up =3D 0 GoTo FIRST_CONDITION EndIF GATE_UP: Gate_Is_Down =3D 0 RELAY_OPEN =3D 1 Pause 1500 RELAY_OPEN =3D 0 Gate_is_Up =3D 1 GoTo FIRST_CONDITION '***END OF PROGRAM --------------59C1114C642919AC129189E1 Content-Type: text/x-vcard; charset=koi8-r; name="mpavlica.vcf" Content-Description: Card for Milan Pavlica (YU7AEC) Content-Disposition: attachment; filename="mpavlica.vcf" Content-Transfer-Encoding: 7bit begin:vcard n:Pavlica;Milan x-mozilla-html:FALSE org:SuperSonic Systems adr:;;;;;; version:2.1 email;internet:mpavlica@ptt.yu title:Chief fn:Milan Pavlica end:vcard --------------59C1114C642919AC129189E1-- -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics