Asked
— Edited
Hello,
i need help for a script for the Ultrasonic Sensor.
How i can make a script for diffrent commands on diffent distances?
My exampel Script
:loop
$proxclose = 30
$proxsense = GetPing(D21,D22)
IF($proxsense < $proxclose)
SayEZB("You are to near")
EndIf
$proxclose = 100
$proxsense = GetPing(D21,D22)
IF($proxsense < $proxclose)
SayEZB("Still to near")
EndIf
Sleep( 2000 )
goto(loop)
Has somebody an idea?
It looks like you are on the right path. Does it not work for you?
Hi JustinRatliff,
no,
The EZB only say the last one for "100"
$proxclose = 100
$proxsense = GetPing(D21,D22)
IF($proxsense < $proxclose)
SayEZB("Still to near")
For the "30" it never comes!
How i can make a command "between"?
It must be :
IF($proxsense is between 70 and 100)
but how to write it correct?
Boris
I can't test this but I think you need to define 2 $proxclose variables. Try this script hopefully more seasoned script writers will jump in and help you out if this doesn't work
@Boris You need to use SayEZBWait on at least the first SayEZB command or the second one will cancel out the first before it has a chance to speak...
My Ping Roam script (which either it's a huge coincidence you chose the same variables I did or you have seen already) should walk you through making adjustments. My notes on Ping Roam should also be a huge help too. Check this topic, I included all of my notes and hand scribbled changes.
Rather than give you the fish I want you to learn to fish. So no code examples here! But you are looking at the IF statement command
And the ElseIf and Else commands.
Use different distance values and either the =, < or > for different actions. Use ControlCommand() to start other scripts, controls, autopositions etc.
And for between values, use the AND or the OR operator