Your code runs in one state at a time.  The state runs repeatedly until the state times out or you switch to a new state.

If a time is entered in the "Run Time" box, the state will run only for that length of time before switching to the next state. Time is in milliseconds (1000 = 1 second).

state = "turnLeft"
Switches to your state named turnLeft.

Pauses running the code for 1000 milliseconds (1 second) while the robot continues to follow the previous instruction.

Stops running the code, exiting your states.

Basic User Interface (UI)

String will appear to the right side of the state in the code editor.

String will appear in the UI window. This is useful for explaining things to the user.

button("Lefty!", "turnLeft")
Creates a button in the UI panel called Lefty!. Pressing this button will run the state named turnLeft.

Creates a checkbox called string. The value of the checkbox is true or false depending on whether it is checked or unchecked, so it can be used as a condition in an "if" statement: if (checkbox("string")) ...

checkbox("string", "store.v")
If the box is checked, the value of store.v is set to true. If the box is unchecked, it is set to false.

power.L=slider("Left", -100, 0, 100)
Creates a slider in the UI to control the left wheel, with range -100 to 100, and the slider first set to 0.

Create2 Driving

Drive forward 10 centimeters.

Drive backward 5 centimeters.

Turn left 45 degrees.

Turn right 90 degrees.

drive(-5, 20)
Sets the speed of the left wheel to -5 and the speed of the right wheel to +20 (range is -100 to 100).

driveToPoint(3, -2)
Turn toward the point on the map given by cartesian coordinates (3, -2), 3 meters to the right and 2 meters down, and drive forward until that point is reached.


power.servo[0] = 90
Moves the first servo to position 90 degrees (range is 0 to 180 degrees)

PWM (Pulse Width Modulation)

power.pwm[0] = 100
Sets the value of the first PWM to 100, full power (range is 0 to 100).

Neopixel LEDs

power.neopixel[0].color = {r:20,g:0,b:0}
Sets all the neopixels to a dim red color.

power.neopixel[0].color = {
Adds sliders in the UI panel to control the neopixel colors.

power.neopixel[0].color = {r:10,g:10,b:10}
power.neopixel[0].accent = {r:100,g:0,b:0}
power.neopixel[0].repeat = 4
power.neopixel[0].start = time/250
Animates a bright red accent on a dim white background.


store.x = 20.0 
store.x = "String"
store.x = store.y
Stores a variable named x and sets it to a number, a string, or the value of another stored variable.

Control Flow

if (expression)
If expression evaluates to true, executes statement1, otherwise executes statement2.