'------------------------------------------------------------------------------------ '-------------Secratary Bot--------------------------------------------------- '----------Signs documents, plays songs-------------- '---------------------------------------------------------------------- ' {$STAMP BS2} ' Stamp directive. ' {$PBASIC 2.5} ' PBASIC directive. ' -----[ Variables ]---------------------------------------------------------- pulseCount VAR Byte ' FOR...NEXT loop counter. ' -----[ Main Routine ]------------------------------------------------------- DO FOR pulseCount = 0 TO 3 PAUSE 10 PULSOUT 13, 750 PULSOUT 12, 650 PAUSE 10 NEXT LOOP GOSUB Lift_Pen DO IF (IN5 = 1) THEN 'Detect Sound GOSUB Lift_Pen ELSEIF (IN0 = 0) THEN ' Left Trigger contacts GOSUB Forward_Pulse ELSEIF (IN1 = 0) THEN ' Down Trigger contacts GOSUB Test ELSEIF (IN2 = 0) THEN ' Right Trigger contacts GOSUB Signature ELSEIF (IN3 = 0) THEN ' Center Trigger contacts GOSUB Drop_Pen ELSEIF (IN4 = 0) THEN ' Up Trigger contacts GOSUB Stand_Still ELSEIF (IN2 = 0) AND (IN4 = 0) THEN 'Center AND Down triggers GOSUB Spin ELSE GOSUB Stand_Still ' Apply a forward pulse ENDIF ' and check again LOOP '-------------------------------------------------------------------------------------------------------------' Test: DO IF (IN5 = 1) THEN 'No Sound FOR pulseCount = 0 TO 3 PAUSE 10 PULSOUT 13, 750 PULSOUT 12, 650 PAUSE 10 NEXT LOOP IF (IN5 = 0) THEN 'Detect Sound GOSUB Lift_Pen ENDIF LOOP ' -----[ Subroutines ]-------------------------------------------------------- Forward_Pulse: FOR pulseCount = 0 TO 20 PAUSE 10 PULSOUT 13, 850 PULSOUT 12, 650 PAUSE 20 NEXT RETURN Spin: PULSOUT 13, 650 PULSOUT 12, 650 PAUSE 20 Signiture_1: FOR pulseCount = 0 TO 20 PAUSE 10 PULSOUT 13, 750 PULSOUT 12, 650 PAUSE 20 NEXT FOR pulseCount = 0 TO 20 PAUSE 10 PULSOUT 13, 650 PULSOUT 12, 850 PAUSE 20 NEXT FOR pulseCount = 0 TO 20 PAUSE 10 PULSOUT 13, 850 PULSOUT 12, 850 PAUSE 20 NEXT FOR pulseCount = 0 TO 20 PAUSE 10 PULSOUT 13, 850 PULSOUT 12, 650 PAUSE 20 NEXT RETURN Drop_Pen: ' lower pen to ground FOR pulseCount = 0 TO 10 PULSOUT 15, 850 PAUSE 20 NEXT RETURN Stand_Still: ' Dont move PULSOUT 13,750 PULSOUT 12,750 PAUSE 20 RETURN Lift_Pen: 'lift pen from ground FOR pulseCount = 0 TO 10 PULSOUT 15, 650 PAUSE 20 NEXT RETURN