Welcome to Synthiam!

The easiest way to program the most powerful robots. Use technologies by leading industry experts. ARC is a free-to-use robot programming software that makes servo automation, computer vision, autonomous navigation, and artificial intelligence easy.

Get Started
Asked — Edited
Resolved Resolved by DJ Sures!

A Variable Range

I cannot get a variable range function to work.

#get compass value

if ($CompassHeading = 145)

Print("Left") # this will actually be a GoTo to allow a motor speed trim value
# to be added or subtracted to the correct motor to get back on

I don't see any range examples in the If function list.

My actual script trims the heading. I will compare the current heading to an allowable value. if the value is within the limit it goes straight. If the deviation is more than or less than the acceptable limit values, it will add or subtract speed to the correct motor to return to the heading.


Upgrade to ARC Pro

Experience early access to the latest features and updates. You'll have everything that is needed to unleash your robot's potential.

In the future, it will be easier to read if you place your code within [ code ] and [/ code ] tags (without the spaces)

Here's a screenshot of the UBB Code legend that's exactly to the right of the input form where you typed the message.

User-inserted image

As for what i think you're asking, is to determine if a number is between two values? If so, the EZ-Script manual is the RIGHT of the code editor. The IF condition manual states this...

User-inserted image

Here is an example that applies to your question...


IF ($compassHeading >= 145 and $compassHeading <= 190)
print("The compass is heading between 145 and 190")

You may wish to try Blockly (by pressing F9 or selecting the Blockly WORKSPACE from the TOP MENU). Blockly will help you create conditions and learn programming logic.

Here's a snapshot of the same code done in BLOCKLY
User-inserted image

Here is a Blockly workspace example that you can load and try for yourself:CompassDirection.ezblockly

Load the example into Blockly by pressing the LOAD WORKSPACE button.

User-inserted image
That answers the question. In PLC logic was a simplified Range function which I used a lot.

The new Blockly will help me get on track.

Yeah I screwed up loading the code example, but your reminder jogged the memory.

Thanks for the help.