
mooshroom27
USA
Asked
— Edited

So I am coding some multi color recognition software in ez-script, but whenever I run the code it says that I am missing a binary operator in the command used to search for a color. pleass note that am running this code on a pc and not on the ez-b code is below
ControlCommand("Camera", CameraMultiColorTrackingEnable)
If($CameraObjectColor()= "color" )
Print("TWO")
Elseif($CameraObjectColor()="color")
Print("ONE")
EndIf
Also, you seem to be asking (in the script) the same thing for the IF and the ElseIF, however that wont throw an error since the IF will take priority and it will PRINT("TWO")
Hopefully that solves it however if it doesn't please post your project's .ezb file and I'll take a look at it (just one script isn't always enough since you will have other variables set up such as the custom colours.
$x = 1
$y = 7
$z = GetADC(ADC0)
$a = GetRandom(0,100)
$calc1 = $y * $a
$text = "This is some text"
That's just a few ways
Basically, all variables begin with the $ character and then are a group of characters without spaces.
$xyz = will set the variable to whatever is after the =. That could be a number, a string (in quotes), a command such as GetADC, GetRandom, GetPWM etc. a calculation such as 1 * 2 + 3 or a calculation with variables like $voltage / $current. You can also use $x++ to increase $x by 1 (I presume it only works for decimal numbers though).
If you want a specific example give me the scenario and I'll explain it. Without a scenario it's difficult to cover every single method of creating variables. A good example to look at for use of variables and setting them are my Ping Roam scripts and my Battery Monitor script. Battery Monitor does some simple calculations too.
Thanks Rich
Code:
This will in theory move the servo on D0 back and forth between 75 and 25.
Hope that helps
[edit]
Rich and I must have been typing at the same time. LOL
Once you define a variable it exists until the session ends. You can then call it and change it from any other script or control.
For instance, run this code and it will throw an error;
Code:
However, if you run this code it will work
Code:
If the variable exists in another script or control ($soundservo, $CameraObjectColor etc) make sure the other script or control has run before you run the script or it will throw an error.
This one for example doesn't even control anything yet (and is a little bit of a hint at what one of my future build's main function will be).
Edit... Ok, LOL.... I can see how ARC can keep one busy indefinitely...
R