Glen, I don't know your PIC basic compiler, but it look like it follows the Parallax Basic Stamp Language. If it is true you misunderstood the meaning off PIN statement. The number after the pin is referred to the portb pin it mean that the PIC pin #6, that is RB0, is PIN0 for basic, and so on. In your program in first IF you compare NUMBER 9 with NUMBER 0 and in the second IF you compare NUMBER 9 with NUMBER 1. Both not compare and you execute 'del' and branch back to main. Try to use the constants below and LMK. '----------- Constants ----- symbol sensor = PIN3 'senses ldr changes symbol out1a = PIN4 'assign pin 10 for label output symbol out1b = PIN5 'assign pin 11 for label output symbol out2a = PIN6 'assign pin 12 for label output symbol out2b = PIN7 'assign pin 13 for label output symbol ac = PIN2 'assign pin 8 for label ac (line sensing) On www.parallaxinc.com there is the possibility of subscribe to a PIC Basic list that is more appropriate for your needs. ciao Claudio Rachiele IW0DZG PICLIST @ MITVMA.MIT.EDU 10/02/99 01:51 Please respond to PICLIST@MITVMA.MIT.EDU To: PICLIST @ MITVMA.MIT.EDU cc: Subject: help pls -1st pbc program hi & thanks for sparing the time ! this is my 1st project using the 16f84 , my first attempt to write a basic program using picbasic(pbc) !!!! You will laugh , i probly would. !!!! any way , its a sunset switch prog., by the way. i am testing this sensor input by simple applying a 1 or 0 to the input. i will replace this with an ldr (cost)then using the vin-vo level to control counters next step.i will also try cap with ldr next. i'm not sure which will be the best untill i test the midpoint hysterisis of the i/p pin couple of problems -it won't go on initially for the 10secs & go off.(???) -when it's high it times out for the 20secs & lamps on , like it should (ok) -but when i change the input pin to low the lamps wont go off .i don't know if it is timing out !(???) i'm not sure if the delay(del) lamp on & off timers are reseting either. if night, keep delay counting (del) if a 0 or if day = 1 reset delay(del) & start day delay(del1) & visaversa any help / advice would be greatly appreciated with my 1st project. i need to get this working correct so i can then use pin 8 to synchronise to AC LINE ( 0 crossing) i would like to upgrade from a relay to use a triac to control some fluro lts , i would like be able to control the firing angle of the triac. i can build this out of discreet components (no problem),but , software control (a challenge) below is my program attempt. thanks , once again. glen ' Title ltsw.bas 'date 990204 '-------------- Progran Description ------------------- 'using the 16f84 pic 'at startup , outputs on for 10 secs, sense an ldr for night or day, 'sense ldr pin change & if pin same input after 20 secs , output on ' ' pic connections ' ' pin 1 - ra2 ' pin 2 - ra3 ' pin 3 - ra4/toc1 ' pin 4 - !mlcr resistor to 5v ' pin 5 - vss to gnd ' pin 6 - rb0/int ' pin 7 - rb1 ' pin 8 - rb2 ac input ' pin 9 - rb3 sensor input ' pin 10 - rb4 out1a ' pin 11 - rb5 out1b ' pin 12 - rb6 out2a ' pin 13 - rb7 out2b ' pin 14 - vdd to 5v ' pin 15 - osc1/clkin ' pin 16 - osc2/clkout ' pin 17 - ra0 ' pin 18 - ra1 '----------- Constants ----- symbol sensor = 9 'senses ldr changes symbol out1a = 10 'assign pin 10 for label output symbol out1b = 11 'assign pin 11 for label output symbol out2a = 12 'assign pin 12 for label output symbol out2b = 13 'assign pin 13 for label output symbol ac = 8 'assign pin 8 for label ac (line sensing) symbol night = 0 'sensor pin 9 i/p = 0 , night symbol day = 1 'sensor pin 9 i/p = 1 , day '----------- Variables ------------- symbol sense = b0 'temporary variable lights on night symbol sense1 = b1 'temporary variable lights off day '------------ Iniialisation --------- 'pins 131211109876 'bits = 76543210 dirs = %00001100 'direction pins for portb(0=op,1=ip) 'pins = 0C '13,12,11,10 outputs.9,8 inputs.7,6 outputs '*** pin 8 for AC LINE sychronise *** '------------ Main Code ---------- start: gosub lton 'turn the 4 output pins on pause 10000 'delay for 10 seconds gosub lton 'turn the 4 output pins off pause 1000 goto main main: if sensor = night then del 'if sensor=0 go to on_timeout loop if sensor = day then del1 'if sensor=1 go to off_timeoutloop del: for sense = 1 to 20 pause 1000 next sense gosub lton goto main del1: for sense1 = 1 to 10 pause 1000 next sense1 gosub ltoff goto main ' end '------------ Sub routines ----------- lton: high out1a high out1b high out2a high out2b return ltoff: low out1a low out1b low out2a low out2b return '----------------