'{$STAMP BS2} '------------------------------------------ 'rcontrol.bs2 ' 'This program reads an input (P6) from an RC 'receiver and uses it to control the drive motor. 'The steering motor and other motors such as camera 'control can be driven directly by the RC receiver. rcin var word 'Pulse width from RC net con 8 'Coprocessor network pin baud con 396 'Coprocessor baud rate here: if in14=1 then here 'Wait for button start: Pulsin 6,1,rcin 'Read the RC if rcin < 500 then stp 'Stop if out of range if rcin > 1000 then stp 'Stop if out of range rcin=(rcin-500)/50 'Scale down value to 0-10 if rcin>7 then gof 'Forward if rcin<3 then gor 'Reverse stp: serout net,baud,["!1M1100000"] 'Stop motor goto start 'Keep doing this 'Forward gof: serout net,baud,["!1M116FFFF"] 'Drive motor forward goto start 'Reverse gor: serout net,baud,["!1M106FFFF"] 'Drive motor reverse goto start