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!

United Kingdom
#1  

What's the code? GetPing isn't a command as such, it must be assigned to a variable, used in an IF statement etc.

I can confirm GetPing() works in the latest version of ARC. Check the EZ-Script help on the right of the EZ-Script dialogue.

United Kingdom
#3  

Paste your code you are trying to use. Although it seems you are not assigning it to a variable or using it in an IF statement.

If you code looks like this

GetPing(d0,d1)

then it is incorrect.

GetPing (and any of the "Get" functions) must be used as part of something bigger, for instnace;

$ping=GetPing(d0,d1)
$random=GetRandom(0,100)

If (GetADC(ADC0) < 100)
#4  

Finished the code and get this error. Block directions - Start Block directions - Error on line 3: Missing String Quotes or Invalid Expression: < Block directions - Done (00:00:00.0156001)

Script:

#Check Left

If (GetPing(d0, d1)=&lt;20)
$Noleft=1
EndIF

#check Forward
If GetPing(d2, d3)=&lt;30)
$Noforward=1
Endif

#Check Right
If (Getping(d4, d5)=&lt;20)
$Noright=1
Endif

This is just a practice script. Plan on doing a lot more work with it.

United Kingdom
#5  

Your problem lies with the if statement. It should be <= not =<

You're also missing the open bracket on the second IF.

You will find this code works;

#Check Left

If (GetPing(d0,d1) &lt;= 20)
$Noleft=1
EndIF

#check Forward
If (GetPing(d2,d3) &lt;= 30)
$Noforward=1
Endif

#Check Right
If (Getping(d4,d5) &lt;= 20)
$Noright=1
Endif
#6  

Also you really don't need to use the = sign in your if statements here. The less than sign is sufficient... the ping return is so varied that it will rarely ever equal any variable/Constant you may have set anyway...

United Kingdom
#7  

You can also replace the = part by increasing the < by 1. <= 20 is the same thing as <21.

Personally I always use the <= but it's personal preference.