ARC provides the JavaScript programming language for custom code that interconnects skills. The ARC JavaScript API provides access to both standard ECMA 5.1 Script specifications and a library of additional functions. The other functions are defined in this section.

JavaScript is not JAVA. JavaScript, often abbreviated as JS, is a programming language that conforms to the ECMA 5.1 Script specification. JavaScript is high-level, just-in-time compiled, and multi-paradigm. It has curly-bracket syntax, dynamic typing, prototype-based object orientation, and first-class functions. JavaScript engines were initially used only in web browsers, but they are now core components of other software systems, such as Synthiam ARC. Although there are similarities between JavaScript and Java, including language name, syntax, and respective standard libraries, the two languages are distinct and differ significantly in design.

The ARC JavaScript engine exposes several objects with methods for interacting with hardware, the framework, and other robot skills. Further down at the end of this document is information on creating global user-defined custom objects and methods.

ARC JavaScript Functions



In addition to the built-in ECMA 5.1 JavaScript classes (outlined below), ARC includes several types with methods to control your robot, read sensors, interact with the operating system, and more. To view built-in ARC JavaScript methods…


1)    Check the intellisense checkbox.


2)    Type one of the following class names, press ‘.’ and scroll through the available methods.


ADC – EZB analog to digital converter functions

Audio – streaming audio functions

COM – local serial COM port functions

Digital – EZB digital I/O functions

EZB – EZB specific functions for getting voltage, checking the connection, etc.

File – writing and reading local files

I2C – EZB I2C helper functions

Movement – movement panel control of directions

Net – networking functions

Ping – EZB ultrasonic distance sensor functions

PWM – EZB pulse width modulation on digital I/O pins

Servo – EZB servo movement functions

UART – EZB hardware UART and software Serial functions

Utility – various utility functions


Supported JavaScript ECMA 5.1 Classes

The JavaScript ECMA 5.1 includes several classes for working with strings, math, and various features. The following classes can be researched online at developer.mozilla.org and w3schools.com for detailed information and examples.



-           Array

-           Boolean

-           Console (support for time, count, error, info, log)

-           Date

-           Error

-           Iterator

-           JSON

-           Map

-           Math

-           Number

-           Object

-           Proxy

-           Reflect

-           RegExp

-           Set

-           String

-           Symbol



Root Commands

Root commands do not belong to a class and are included for convenience to access global variables and send commands to other controls.



getVar( variableName, [default value] )

Retrieves the value from the Arc’s public global variable storage. These are variables published by robot skills, such as the Camera, Auto Position, Speech Recognition, etc...


{variableName} - The name of the global variable as a string

{default value} – [Optional] If specified, this value is returned if the global variable doesn’t exist.

{return} – The value of the global variable



// Get the current direction the robot is moving

var direction = getVar(“$Direction”);


// Get the value of $test, and if it doesn’t exist return false

var testVar = getVar(“$test”, false);



setVar( variableName, value )

Sets the value from Arc’s public global variable storage. This allows the variable to be available to other controls or scripts by using getVar().


{variableName} - The name of the global variable as a string

{value} – The value that you wish to store in the global variable

{return} – The value of the global variable



// Set a value of 5 to be accessible by other controls

setVar(“$MyValue”, 5);



varExists( variableName )

Check if the global variable exists.


{variableName} - The name of the global variable as a string

{return} – true/false Boolean if the variable exists



// print if the variable exists




print( txt )

Writes the value to the console output.


{txt} – The value/data to print



// Print a string to the console output

print(“Hello World”);



sleep( timeMs )

Pauses the execution of the program for the specified time in milliseconds


{timeMS} – The time to pause



// Print a string, pause for 5 seconds and print another string



print(“ World”);



sleepRandom( minTimeMS, maxTimeMS )

Pauses the program's execution for random milliseconds between the min and max.


{minTimeMS} – The minimum time to pause

{maxTimeMS} – The maximum time to pause



// Print a string, pause for a random time and print another string


sleepRandom(1000, 5000);

print(“ World”);



controlCommand( control name, command, [parameters] )

Sends the command to the control name with the optional parameters. The cheat sheet displays all of the interrogated control commands supported by controls in the project.




// Start the camera

controlCommand(“Camera”, “StartCamera”);

print(“Camera has started”);



showControl( controlName )

Shows the user interface control. This also adds the control to the stack, which can be




// Start the camera

controlCommand(“Camera”, “StartCamera”);

print(“Camera has started”);



closeControl( controlName )

Closed the user interface control and displayed the previous control in the display stack.








JavaScript variables are private to the namespace of each script engine. That means a variable created in a JavaScript script does not exist in other JavaScript scripts. If you have variables declared in the JavaScript of the Camera control, the variables are not accessible in the JavaScript of the WiiMote control.


Public variables use ARC’s variable manager, which is global across all controls and compilers. Public variables are accessed using the getVar() and setVar() JavaScript commands.

Blockly generates JavaScript, which means the variables will be private by default. The variables can start with a $ (dollar sign) to be public

Custom JavaScript Extension

The ARC JavaScript engine exposes the ability to extend the built-in objects with user-defined custom objects. These custom objects can be either methods, variables, or entire classes. There is an example of doing this in the Create Robot Skill manual. Access it by Clicking Here.