'4/2/7 vtop: b2 = 0 'initial count serin 2,n2400,b5,b3 'b5=command o,c,r b3=count 0-255 if b5 = 114 then resetpos if b5 = 99 then openup if b5 = 111 then closeup pulsecount: b0 = pins 'read input pins if b2 = b3 then stoprot 'position reached if bit9 = 1 and bit7 = 1 then stoprot if bit10 = 1 and bit0 = 1 then stoprot if bit1 = 1 and bit8 = 0 then setbit if bit1 = 0 and bit8 = 1 then clearbit goto pulsecount setbit: bit8 = 1 b2 = b2 + 1 goto pulsecount clearbit: bit8 = 0 b2 = b2 + 1 goto pulsecount stoprot: pins = 0 serout 3,n2400,("A") bit10 = 0 bit9 = 0 goto vtop openup: if bit7 = 1 then stoprot high 1 bit9 = 1 bit10 = 0 'bit 9 = opening goto pulsecount closeup: if bit0 = 1 then stoprot high 0 bit10 = 1 'bit 10 = closing bit9 = 0 goto pulsecount resetpos: b0 = pins high 0 if bit0 = 1 then stoprot: goto resetpos