;sensor following camera panning
'28x2 on shield Base and instant robot shield
' picaxe pin assignment for DC motor
;S.8 Motor A Direction
;S.9 Motor A Control (On/Off/PWM)
;S.10 Motor B Control (On/Off/PWM)
;S.11 Motor B Direction
setfreq m16
#picaxe 28x2
#no_data 'Prevent data from being downloaded to PICAXE._
symbol sen_L = pina.0 'Assign symbol sen1_in to input 0
symbol sen_R = pina.1 'Assign symbol sen2_in to input 2
symbol motor_A_dir = s.8 ;s.8 Motor A Direction
symbol motor_A = s.9 ;S.9 Motor A Control (On/Off/PWM)
; symbol motor_B = s.10 ;S.10 Motor B Control (On/Off/PWM)
; symbol motor_B_dir = s.11 ;S.11 Motor B Direction
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;P R O G R A M
start:
b1 = sen_r ;not needed but for debug
b2 = sen_l ;not needed but for debug
if sen_R = 0 and sen_L = 0 then gosub motorOFF ;goto stop motor
if sen_R = 0 and sen_L = 1 then gosub right
if sen_L = 0 and sen_R = 1 then gosub left
; debug
; pause 500
left:
High motor_A_dir ;set direction of motor
goto motorA ;goto start motor
goto start
right:
low motor_A_dir ;set direction of motor
goto motorA ;goto start motor
goto start
motorA:
high motor_a ;start motor
goto start
motorOFF:
low motor_A ;stop motor
goto start
end