as far as updates go i only have what we already know. it works but my intention was to get the hex to walk back once the body move has reached its limit. ill work on this once i get time.
[code]
scantable bytetable 80,80,80,80,80,80,80,80,80,78, |
76,74,72,70,68,66,64,62,60,59, |
58,57,55,53,52,51,50,49,48,47, |
45,43,42,41,40,39,38,37,35,33, |
32,31,30,30,29,29,28,28,27,27, |
26,26,26,25,25,25,24,24,24,23, |
23,22,22,21,21,20,20,20,19,19, |
18,18,18,17,17,16,16,16,15,15, |
15,14,14,13,13,13,12,12,11,11, |
11,10,10,10,10,10,10,10,10,10
;-------------------------------------------------------
scanrange var sword ’ A/D result variable
;-------------------------------------------------------
IF (DualShock(2).bit1 = 0) THEN ;R2 Button test
; [SENSOR DATA CALCULATION]
SensorInput:
adin P19,scanrange ’ Read sensor value
if scanrange > 200 then ’ Test for obstacle to close to detector default and max =512
BodyPosZ = BodyPosZ-10 ’ Move body back
Sound P9,[20\400]
else
if scanrange < 200 then ’ Read sensor value
BodyPosZ = 0 ’ Move body to center (WAS BodyPosZ = BodyPosZ+10)
floating = tofloat( scanrange) / 5.12 ' Limit value to <200 values
val = scantable(toint floating) ' Convert A/D to measurement
debug [REAL floating," ",DEC val,13] ' Output result to debug window
serout S_OUT,i38400,[REAL floating\2," - ",DEC val," cm",13]
else
IF BodyPosZ > 5 then ' Detect body move distance limit
TotalTransZ = 10 ' Walk back
TravelLengthZ = 10
ENDIF
ENDIF
ENDIF[/code]