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=200 GOSUB turn_lt 'spin around to the left GOSUB stp PAUSE 2000 GOSUB turn_rt 'spin around to the right GOSUB pinecrest 'say "I think I am at Pinecrest school" 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 saystop 'say he found an object RANDOM rndnum tm=(rndnum/2)+20 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... - - - - - - - - - - - - - - - - - - - - - - - - ' – subprograms – 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: 'look left FOR I=1 to 20 PULSOUT head,lk_lt PAUSE 20 NEXT RETURN look_rt: 'look right FOR I=1 to 20 PULSOUT head,lk_rt PAUSE 20 NEXT RETURN look_st: 'look straight 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