'Rodo's science fair software '---- declarations ---- '==================================== 'Allophone set addresses '==================================== PA1 CON 0 'PAUSE 10MS PA2 CON 1 'PAUSE 30MS PA3 CON 2 'PAUSE 50MS PA4 CON 3 'PAUSE 100MS PA5 CON 4 'PAUSE 200MS OY CON 5 'Boy AY CON 6 'Sky EH CON 7 'End KK3 CON 8 'Comb PP CON 9 'Pow JH CON 10 'Dodge NN1 CON 11 'Thin IH CON 12 'Sit TT2 CON 13 'To RR1 CON 14 'Rural AX CON 15 'Succeed MM CON 16 'Milk TT1 CON 17 'Part DH1 CON 18 'They IY CON 19 'See EY CON 20 'Beige DD1 CON 21 'Could UW1 CON 22 'To AO CON 23 'Aught AA CON 24 'Hot YY2 CON 25 'Yes AE CON 26 'Hat HH1 CON 27 'He BB1 CON 28 'Business TH CON 29 'Thin UH CON 30 'Book UW2 CON 31 'Food AW CON 32 'Out DD2 CON 33 'Do GG3 CON 34 'Wig VV CON 35 'Vest GG1 CON 36 'Got SH CON 37 'Ship ZH CON 38 'Azure RR2 CON 39 'Brian FF CON 40 'Food KK2 CON 41 'Sky KK1 CON 42 'Can't ZZ CON 43 'Zoo NG CON 44 'Anchor LL CON 45 'Lake WW CON 46 'Wool XR CON 47 'Repair WH CON 48 'Wig YY1 CON 49 'Yes CH CON 50 'Church ER1 CON 51 'Fir 160MS ER2 CON 52 'Fir 300MS OW CON 53 'Beau DH2 CON 54 'They SS CON 55 'Vest NN2 CON 56 'No HH2 CON 57 'Hoe OR1 CON 58 'Store AR CON 59 'Alarm YR CON 60 'Clear GG2 CON 61 'Guest EL CON 62 'Saddle BB2 CON 63 'Business '==================================== i VAR WORD 'counter tm VAR WORD 'how much time to move ltrt VAR BIT 'turn left or right when object detected rndnum VAR BYTE 'Random Number allo VAR BYTE 'holds current allophone std VAR IN15 'stud sensor lmotor CON 11 'left motor rmotor CON 10 'right motor head CON 12 'head servo ls CON 727 'left stop rs CON 720 'right stop lf CON ls+150 'run the left motor, forward lb CON ls-150 'run the left motor, backward rf CON rs-150 'right forward rb CON rs+150 'right backward lk_lt CON 500 'position to look left lk_rt CON 1100 'position to look right lk_st CON 820 'position to look straight 'Set ports 0-5 as outputs DIRL = %00111111 'Set port 8 as input DIR8 = 0 'Set port 9 as outut DIR9 = 1 'Make ports 0 - 7 all lows OUTL=0 PAUSE 2000 'wait 2 seconds before starting GOSUB where 'say "Where am I" PAUSE 1000 'pause for 1 second GOSUB look_lt 'look to the left PAUSE 1000 GOSUB look_st 'look straight ahead PAUSE 1000 GOSUB look_rt 'look to the right PAUSE 1000 GOSUB look_st 'and look straight again PAUSE 2000 tm=150 GOSUB turn_lt 'spin around to the left GOSUB stp PAUSE 100 GOSUB turn_rt 'spin around to the right PAUSE 1500 GOSUB stp PAUSE 500 GOSUB pinecrest 'say "I think I am at Pinecrest school" PAUSE 1000 GOSUB hello 'say "hello" GOSUB look_lt PAUSE 500 GOSUB look_st GOSUB name 'say "My name is..." PAUSE 1000 '---- main loop ---- 'rodo roams around the room main: IF std=0 THEN a 'read stud sensor GOSUB stp GOSUB detect 'say something about finding an object tm=(rndnum/2)+20 GOSUB back 'back up RANDOM rndnum IF rndnum>127 THEN b 'randomly turn left or right GOSUB turn_lt 'turn left GOTO a: b: GOSUB turn_rt 'turn right a: RANDOM rndnum GOSUB fwd 'move Rodo forward GOTO main 'keep on doing it... '---- subs ---- fwd: 'drive forward PULSOUT lmotor,lf PULSOUT rmotor,rf RETURN back: 'backwards FOR i=1 to tm PULSOUT lmotor,lb PULSOUT rmotor,rb PAUSE 20 NEXT RETURN stp: 'stop FOR i=1 to 20 PULSOUT lmotor,ls PULSOUT rmotor,rs PAUSE 20 NEXT RETURN turn_lt: 'turn left FOR i=1 to tm PULSOUT lmotor,lb PULSOUT rmotor,rf PAUSE 20 NEXT RETURN turn_rt: 'turn right FOR i=1 to tm PULSOUT lmotor,lf PULSOUT rmotor,rb PAUSE 20 NEXT RETURN look_lt: FOR I=1 to 20 PULSOUT head,lk_lt PAUSE 20 NEXT RETURN look_rt: FOR I=1 to 20 PULSOUT head,lk_rt PAUSE 20 NEXT RETURN look_st: FOR I=1 to 20 PULSOUT head,lk_st PAUSE 20 NEXT RETURN hello: i=0 hello1: IF IN8=1 then hello1 lookup i,[hh2,eh,ll,ax,ow,1,64],allo if allo=64 then hello2 OUTL=allo PULSOUT 9,3 i=i+1 GOTO hello1 'done hello2: RETURN where: i=0 where1: IF IN8=1 then where1 lookup i,[ww,er2,3,ae,mm,3,aa,ay,1,64],allo if allo=64 then where2 OUTL=allo PULSOUT 9,3 i=i+1 GOTO where1 'done where2: RETURN pinecrest: i=0 pinecrest1: IF IN8=1 then pinecrest1 lookup i,[aa,ay,3,th,ih,ng,kk1,3,aa,ay,3,ae,mm,3,ae,tt1,3,pp,ay,nn1,3,kk1,rr2,eh,ss,tt1,3,ss,kk2,uh,uh,ll,1,64],allo if allo=64 then pinecrest2 OUTL=allo PULSOUT 9,3 i=i+1 GOTO pinecrest1 'done pinecrest2: RETURN name: i=0 name1: IF IN8=1 then name1 lookup i,[mm,aa,ay,3,nn2,ey,mm,3,ih,zz,3,ar,2,zz,yr,ow,2,dd2,iy,2,zz,yr,ow,4,4,yy1,uw2,3,kk1,ae,ae,nn1,3,kk1,ao,ao,ll,3,mm,ey,3,rr1,ow,2,dd2,ow,1,64],allo if allo=64 then name2 OUTL=allo PULSOUT 9,3 i=i+1 GOTO name1 'done name2: RETURN detect: RANDOM rndnum if rndnum<85 then ssay1 'saying 1 if rndnum>170 then ssay2 'saying 2 GOSUB say3 GOTO ddone ssay1: GOSUB say1 GOTO ddone ssay2: GOSUB say2 ddone: RETURN say1: 'object detected i=0 say11: IF IN8=1 then say11 lookup i,[aa,bb1,2,jh,eh,kk2,tt1,4,dd2,iy,2,tt2,eh,kk1,tt2,eh,dd1,1,64],allo if allo=64 then say12 OUTL=allo PULSOUT 9,3 i=i+1 GOTO say11 'done say12: RETURN say2: 'whoops i=0 say21: IF IN8=1 then say21 lookup i,[ww,uh,uh,pp,ss,1,64],allo if allo=64 then name2 OUTL=allo PULSOUT 9,3 i=i+1 GOTO say21 'done say22: RETURN say3: 'oh no i=0 say31: IF IN8=1 then say31 lookup i,[ow,3,nn2,ow,1,64],allo if allo=64 then say32 OUTL=allo PULSOUT 9,3 i=i+1 GOTO say31 'done say32: RETURN