10 REM "The pin setting for Arduino or ESP32" 20 REM SP=27: TP=17: EP=16 30 SP=6: TP=4: EP=5 300 REM "The function for the servo and the echo, integer safe!" 310 DEF FNP(A)=40+A*200/180 320 DEF FNE(P)=P/29*100/2 1000 REM "Look around once" 1010 GOSUB 10000 1020 FOR J=1 TO 5 1030 PRINT J, E(J) 1040 NEXT 1050 END 10000 REM "The look around code" 10060 FOR J=1 TO 5 10070 A=(J-1)*45: GOSUB 12000: GOSUB 11000: E(J)=E 10120 NEXT 10130 A=90: GOSUB 12000 10190 RETURN 11000 REM "Echo once and return the value in E" 11010 DWRITE TP,0: PULSE TP,10 11020 E=FNE(PULSE(EP,1,70)) 11030 RETURN 12000 REM "The servo code" 12010 DWRITE SP,0 12020 FOR I=1 TO 40: DELAY 20: PULSE SP,FNP(A): NEXT 12030 RETURN