; Richard Irons 02/25/2003 ; Lab 5 - Cricket control code global [distance pitch] ; Read distance from sonar to get_reading bsend $180 ; activate the sonar bsend 3 ; emit three pings ;Return contact distance sent by logochip output bsr 0 end to main loop [ ; Activate sonar if switch a is on if sensora = 0 [ setdistance get_reading if distance > -1 [ setpitch (distance + 20) note pitch 2 ] ] ; De-activate sonar if switch a is off if sensora [ bsend $181 ] ] end