> The first switch will start a program where a 1/2 second pulse As Matt Marsh has said, you really ought to get the chip working first otherwise any programming you do has got nowhere to go ---------------------------------- This is fairly simple in-line code that doesn't use interrupts. Not glamorous at all, but it's a pretty straight-forward job that doesn't require much sophistication. Note that it's untested and commits the PIC entirely to looping, which would not be the case if you used interrupts. But it's simple and hopefully you can follow it well enough to be able to build on Note also that "status,z" is not how most people would use the Zero flag, but it's clearer for you. It can be defined #define zero status,2 ;or status,z or tests made into macros, for example skpz macro ;skip next if Z=1 btfss status,2 endm MPLAB also allows the use of the BZ and BNZ branch instructions Anyway....... The timing of this is based on a 32.768kHz crystal, no pre-scaler, which will make TMR0 rollover 32 times / sec = (32768/4)/256 The 12F675 has a 16-bit TMR1, but the F84A doesn't. The F628 (F84A replacement) does too, but it hardly matters in this case. There are many ways to do what you want, this is just one. If you did use a 16-bit timer, then a /8 prescaler would produce 1/4s roll-overs, which would simplify the code. /16 is available for TMR0 to get 1/2s rollovers A couple of things you didn't specify. Are the switches toggle or momentary (you may need to test for switch release) and is the first timing period a pulse or a gap ? This code will do (pulse-space) x 5, repeat with modifications to do the second part clrf tmr0 ;initialise TMR0 movlw .5 ;initialise pulse counter movwf pulse_cnt clrf ro_cnt ;initialise rollover counter btfss switch1 ;wait for switch closure goto $-1 bsf pulse ;set output high initially ;hold pulse on for 1/2 second wait1 btfss intcon,t0if ;wait for TMR0 rollover goto wait1 bcf intcon,t0if incf ro_cnt ;increment rollover count movlw .16 ;test if = 16 = 1/2 second xorwf ro_cnt,w btfss status,z ;yes (zero flag = 1 = match) goto wait1 ;no bcf pulse ;set output low ;wait for 1 second clrf ro_cnt ;reset rollover counter wait2 btfss intcon,t0if ;wait for TMR0 rollover goto wait2 bcf intcon,t0if incf ro_cnt ;increment rollover count movlw .32 ;test if = 32 = 1 second xorwf ro_cnt,w btfss status,z ;yes goto wait2 ;no clrf ro_cnt ;reset rollover counter decfsz pulse_cnt ;bump pulse counter goto wait1 ;not done, repeat ;Part 2 btfss switch2 goto wait2 etc -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body