' *** QUICK-REACTION For PicAxe08 *** Ver 1.0 Oct 2003 Minor comments by Stan. SWAN ' (Program unchanged except b0 now 120) Download => www.picaxe.orcon.net.nz/reaction.bas ' 127 bytes used as is - perhaps scope to refine sounds (since greedy syntax !) at least ? '----------------------------------------------------------------------------------------- ' A game of response skill from the UK, by Tom Lynas (age 10) and Bob Lynas (age 37!). ' =>bob.lynas@simrad.com (could also be used to gauge when you have had too much to drink !!!) ' THOUGHT: Build into a discarded computer mouse - use a mouse button for the push key ? ' Otherwise use a normally open push switch built into a 35mm plastic film cannister for key. ' ' "08" CONNECTION DETAILS ( also see pix =>www.picaxe.orcon.net.nz/reaction.jpg ) ' TOP VIEW ' 3-5V +V Supply - [1 8] - Supply 0V ' Serial ProgIn - [2 7] - Serial ProgOut ' Red LED Ch.4- [3 6] - Ch.1 Green LED ' Key switch to +V & 10k to 0V Ch.3- [4 5] - Ch.2 Peizo sounder ' ' NB:10k pull-down resistor from the switch input to 0V stops "floating" 0/1 values ' ' GAME RULES: ' At the start a short tune will play, the ch. 4 red LED will come on indicating "ready ?" & ' a pseudo random pause is then generated. When the green LED comes on you must press the key ' as soon as you can. If you pass with quick reflexes, a short jolly tune will play,but if you ' fail then a 'raspberry' tune sounds. If you try and press the key before the green LED you'll ' fail as well. You get 10 attempts to beat the timer. After 10 goes, a short tune will play & ' your score will be heard as 'beeps'.To restart the game you must press the key again. At the ' end of the game LEDs are unlit to conserve battery power. Alter b0 if time of 11 0 too brisk. Start: sound 2,(116,10,118,10,119,10,120,50) ' GAME START tune wait 2 let b3 = 0 ' clear (previous) score for b2 = 1 to 10 ' maximum of 10 tries low 1 ' switch green LED off high 4 ' switch red LED on (Wait...) sound 2,(120,10,0,10,120,30) ' ARE YOU READY ?? wait 2 ' 2 sec pre-delay random b1 ' make further pseudo random delay pause b1 ' '' '' pause b1 ' '' '' let b0 = 0 ' clear the timer count high 1 ' switch green LED on (GO !!) low 4 ' switch red LED off if pin3 = 1 then Fail ' holding the key is cheating !! Timer: if pin3 = 1 then Pass ' reacted well !! let b0 = b0 + 1 ' increment timer count if b0 < 110 then Timer ' didn't react within 110 loop cycles Fail: sound 2,(40,10,0,20,2,40) ' FAILED "raspberry" sound ! goto Next_try Pass: sound 2,(120,10,118,10,122,10,120,20) ' PASSED sound let b3 = b3 + 1 ' increment score Next_try: wait 1 ' delay before next try next b2 ' do next try Scoring: wait 1 sound 2,(120,10,119,10,118,10,116,50) ' SCORE tune for b4 = 1 to b3 ' Loop for score beeps pause 500 ' make gap between beeps sound 2,(116,b3) ' longer beeps for higher scores next b4 ' another beep (number heard = score)? low 1 ' switch green LED off Restart: if pin3 = 0 then Restart ' wait for key press to restart game goto Start ' start again