'Basic Stamp II program Archery 'this program is copyright A.Ron Carmichael, 2000. It may be used and reproduced 'noncommercially but may not be sold. ' 5432109876543210 dirs = %1111111111110000 'Define output (1) ports outs = %0000000000000000 'Set the States of the ports (all off) 'pins 00 and 01 are pushbuttons 'pin 02 is a slide switch to indicate one or two lines of archers 'declare variables '**************** swtch var byte Walk var byte shooting var byte alert var byte lupe var byte endit var bit setswitch var byte main_loop var byte countdown var byte tempbutton var byte SHORTLONG var byte(10) ' An array to hold the string. LETTERS var byte (2) 'array for the letter s for plural lines ' default values '**************** main_loop = 0 'minute for main cycle countdown = 0 'count down from swtch = 0 'if 1 then two lines of archers controlled by switch on pin 02 endit = 0 'if > 1 then stop processing lupe Start: 'turn red led & light on out15=1 out11=1 Stp1: pause 500 GOSUB BEEP '1 beep when powered up or reset serout 10,16468,[254,128,"Set Switch For "] serout 10,16468,[254,192,"# Archer Lines "] pause 2000 gosub clearscreen for setswitch = 4 to 1 serout 10,16468,[254,128,"Switch Polled In"] serout 10,16468,[254,192,dec setswitch , " seconds......."] PAUSE 1000 setswitch = setswitch - 1 next gosub clearscreen IF IN2 = 0 then TWOLINES 'check slide switch Swtch = 1 serout 10,16468,[254,128,"1 line selected"] pause 1000 goto CHOOSEDISTANCE TWOLINES: Swtch = 2 serout 10,16468,[254,128,"2 lines selected"] LETTERS(0) = "s":Letters(1)=1 pause 1000 goto CHOOSEDISTANCE CHOOSEDISTANCE: 'outs = %0000100000000000 'turn red led & light on out15=0 out11=1 gosub clearscreen serout 10,16468,[254,128,"Choose Distance!"] serout 10,16468,[254,192," LONG or SHORT"] WaitFerButton: button 0,0,200,255,tempbutton,1,shortdist' wait for input on button 'when pressed start a slow timing loop button 1,0,200,255,tempbutton,1,longdist 'if pressed then this should be 3.5 minute timing loop goto WaitFerButton '************* SHORTDIST: '2 minute timer gosub clearscreen ShortLong(0) = "S":ShortLong(1) = "h" ' Store "Short" in first 5 cells... ShortLong(2) = "o":ShortLong(3) = "r" ShortLong(4) = "t":ShortLong(9) = 5 'Put length (5) in last cell* 'debug str ShortLong\ShortLong(9) ' Show "SHORT" on the PC screen. 'serout 10,16468,[254,128, str shortlong] 'pause 1000 'pause 500 main_loop = 120 countdown = 120 'outs = %0000101000000000 'Set pin 9 to turn on the 1.5 LED indicator out9=1 'and pin 11 to turn on the RED LED indicator out11=1 '1.5 minute cycle green LED indicator 'red LED indicator while 20 seconds elapse 'out8 = 3.5 minute LED goto MAIN '########## LONGDIST: '3.5 minute timer ShortLong(0) = "L":ShortLong(1) = "o" ' Store "HELLO" in first 5 cells... ShortLong(2) = "n":ShortLong(3) = "g" ShortLong(4) = " ":ShortLong(9) = 5 'Put length (5) in last cell* 'debug str ShortLong\ShortLong(9) ' Show "LONG " on the PC screen. 'serout 10,16468,[254,128, str shortlong] MAIN_LOOP = 240 COUNTDOWN = 240 ' 5432109876543210 'outs = %0000100100000000 out8=1 out11=1 goto MAIN MAIN: FOR lupe = SWTCH to 1 'if 2 lines of archers will repeat once gosub clearscreen 'serout 10,16468,[254,128,"Mswitch = ",dec swtch ] 'serout 10,16468,[254,192,"Mlupe = " , dec lupe ] 'pause 1000 ' 5432109876543210 'outs = %0000100000000000 'Set pin 9 to turn on the 1.5 LED indicator 'and pin 11 to turn on the RED LED indicator '1.5 minute cycle green LED indicator out11=1 'red LED indicator while 20 seconds elapse out15=1 'put a beep here to walk to line during 20 secs GOSUB BEEP out15=0 GOSUB NOBEEP out15=1 GOSUB BEEP out15=0 gosub clearscreen for walk = 19 to 1 'pause 20 secs counting 2 secs for beeps to air pause 930 'debug dec ? walk serout 10,16468,[254,128,"Shooting ",dec swtch," Line",str LETTERS] serout 10,16468,[254,192,"Shoot in ",dec walk," secs"," "] 'go to line two next ' 5432109876543210 'outs = %1010000000000000 out15=1 out11=0 out13=1 pause 700 out15=0 GOSUB BEEP 'one beep = start shooting pause 700 'outs = %0010000000000000 gosub clearscreen for shooting = countdown to 29 'debug dec ? shooting pause 930 serout 10,16468,[254,128,"Shooting ", str SHORTLONG] serout 10,16468,[254,192,dec shooting, " seconds left "] next 'go back to for until var shooting = 1 YELLOW: ' 5432109876543210 'outs = %0001000000000000 'Set pin 9 for 1.5 indicator and 12 for YELLOW out13=0 'pin 13 goes OFF (GREEN) out12=1 'don't change whichever pin is on for cycle(9 or 8) gosub clearscreen serout 10,16468,[254,128," YELLOW ALERT!! "] for alert = 29 to 1 'pause 30 secs 'debug dec ? alert serout 10,16468,[254,192," ",dec alert, " seconds left "] pause 930 next if lupe = 2 then AGAIN ' 5432109876543210 out12=0 out11=1 out15=1 'turn red led & red light and HORN lights on gosub BEEP out15=0 'horn light off GOSUB NOBEEP out15=1 'horn light on GOSUB BEEP out15=0 'horn light off GOSUB NOBEEP out15=1 'horn light on GOSUB BEEP out15=0 'horn light off gosub clearscreen serout 10,16468,["Shooting Done "] pause 2000 out9=0 out8=0 goto CHOOSEDISTANCE AGAIN: 'go again ' 5432109876543210 'outs = %1000100000000000 'turn red led & light on out12=0 'yellow out11=1 'red out9=0 '2 minute short out8=0 '4 minute long gosub clearscreen serout 10,16468,[254,128," Line Done "] pause 100 gosub clearscreen NEXT 'first shooting line is done, shoot second by returning to MAIN CLEARSCREEN: serout 10,16468,[254,1] ' clear screen return BEEP: Freqout 7,700,2500,3500 return NOBEEP: Freqout 7,200,0 return