SSC-32 Servo Controller V2 icon SSC-32 Servo Controller V2 — Bridge ARC to Lynxmotion SSC-32: maps V0-V31 to SSC-32 channels for reliable, high-performance serial control via USB, EZB/Arduino UART. Try it →
Canada
YouTube
Asked — Edited
1 Participant

Why Doesn't This Script Work Any More?

I have just switched over to the new 3 port Ultrasonic Sensors and this script will no longer work. It's the one I used for the 4 port Ultrasonic Sensor. The script always Prints 2 no matter how close I get an object to the sensor.


$Center = GetPing(D11,D11)

$close = 40

:start
if($Center < $close)
print(1)
else
Print(2)
endif

Sleep(2000)
Goto(start)

I have tried a 4 port sensor and it won't work either. Was there a change that I missed?


ARC Pro

Upgrade to ARC Pro

Get access to the latest features and updates before they're released. You'll have everything that's needed to unleash your robot's potential!

Author Avatar
PRO
USA
#1  

@bhouston,

Try this:


$close = 40

#--- loop block ----
:start

#inside the loop
$Center = GetPing(D11,D11)

if ($Center < $close)
  print(1)
ELSE
  Print(2)
endif

Sleep(2000)

Goto(start)
#--- loop block ----
Author Avatar
PRO
USA
#2  

I don't have a 3 wire Ping, the 4 wire is working.


:loop

# D21=Trigger=White
# D22=Echo=Green
$distance=GetPing(D21,D22)

print("Distance: " + $distance)

Sleep(1000)
Goto(loop)
#3  

Thanks Pedro, that worked. Copying and pasting got me on that one.