' ========================================================================= ' ' File....... Paintball.BS2 ' Purpose.... ' Author..... Jon Williams -- Parallax, Inc. ' E-mail..... jwilliams@parallax.com ' Started.... ' Updated.... 27 DEC 2005 ' ' {$STAMP BS2} ' {$PBASIC 2.5} ' ' ========================================================================= ' -----[ Program Description ]--------------------------------------------- ' -----[ Revision History ]------------------------------------------------ ' -----[ I/O Definitions ]------------------------------------------------- Trigger PIN 0 TrMode PIN 1 ' trigger mode Solenoid PIN 15 ' -----[ Constants ]------------------------------------------------------- Shoot CON 0 ' for active-low input Release CON 1 MdSingle CON 1 ' single shot mode MdBurst CON 0 ' burst mode IsOn CON 1 ' for active-high output IsOff CON 0 ' -----[ Variables ]------------------------------------------------------- shots VAR Nib ' burst mode shots counter ' -----[ EEPROM Data ]----------------------------------------------------- ' -----[ Initialization ]-------------------------------------------------- Reset: LOW Solenoid ' make output and off ' -----[ Program Code ]---------------------------------------------------- Main: IF (Trigger = Shoot) THEN IF (TrMode = MdSingle) THEN ' single shot mode GOSUB Fire_Solenoid ' fire! ELSE FOR shots = 1 TO 6 ' do 6 shots GOSUB Fire_Solenoid IF (Trigger = Release) THEN EXIT ' escape burst if released NEXT ENDIF DO : LOOP WHILE (Trigger = Shoot) ' force trigger release ENDIF GOTO Main ' -----[ Subroutines ]----------------------------------------------------- Fire_Solenoid: Solenoid = IsOn ' activate PAUSE 100 ' hold on Solenoid = IsOff ' deactivate PAUSE 100 ' recovery delay RETURN