%
;Ext1 output 'running light'
;direction is based on Input1 and Input2 pin values
;this g-code runs in endless loop 
;  M64 arguments:
;    M64 H<ssel> Q<value> [L<length>]

#<pin> = 0
#1 = 0
o10 while[#1 LT 100]
  o100 if[AND[#<_hw_input>,1]]
	  o1010 if[#<pin> LT 7]
      #<pin> = [#<pin> + 1]
    o1010 endif
	o100 elseif[AND[#<_hw_input>,2]]
    o1020 if [#<pin> GT 0]
      #<pin> = [#<pin> - 1]
    o1020 endif
  o100 endif

  M64 H1 Q[2 ** #<pin>] L10
  G09
o10 endwhile
%