Ok. Excuse me for the mistake, the correct sequence is > to coil a1: 1000 > to coil b1: 0010 > to coil a2: 0001 > to coil b2: 0100 the source code in CH Flash Basic is as follows and works well. Regards, Augusto PIC 16F84A FREQ 4 OSCILLATOR CRYSTAL BYTE left, right BYTE null, key_down, ou(5), i, pulse_out SetPort B, %00000000 SetPort A, %01111 ou(1)=%00010000 ; Pulse for RB4 ou(2)=%00000100 ; Pulse for RB3 ou(3)=%00000010 ; Pulse for RB2 ou(4)=%00001000 ; Pulse for RB1 null=%00000000 PortOut B, null ; Turn off all RB4s left=0 ; key left RA0 depressed right=0 ; key left RA1 depressed i=1 ; index for ou( i ) array main : GOSUB read_pa ; read port A IF left=0 THEN GOTO izq_c_r ; key left is depressed END IF IF right=0 THEN GOTO der_c_r ; key right is depressed END IF PortOut B, null ; turn off any pulse to coils GOTO main read_pa : PinRd A, 0, left ; read for left key PinRd A, 1, right ; read for right key RETURN der_paso : i=i+1 ; index to next pulse to be used IF i>4 THEN i=1 END IF pulse_out=ou(i) ; set pulse to be sended to port RB PortOut B, pulse_out ; set the pulse out, this sentence never works with an array variable GOSUB delay_20 ; keep the pulse "on" 10 mS RETURN izq_paso : i=i-1 ; index to previous pulse to be used IF i=0 THEN i=4 END IF pulse_out=ou(i) ; set pulse to be sended to port RB PortOut B, pulse_out ; set the pulse out, this sentence never works with an array variable GOSUB delay_20 ; keep the pulse "on" 10 mS RETURN der_c_r : GOSUB der_paso ; perform one step right GOSUB read_pa ; read port RA IF right=0 THEN ; if the key is holded down GOTO der_c_r ; loop END IF GOTO main : key released izq_c_r : GOSUB izq_paso ; perform one step left GOSUB read_pa ; read port RA IF left=0 THEN ; if the key is holded down GOTO izq_c_r ; loop END IF GOTO main : key released delay_20 : Delay 10, 0 ; delay 10 mS RETURN -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu