Sphero Command The Sphero Blocks - Here is a Description of what each does Variable Ranges
Combines heading, speed and time variables to make the robot roll. Duration
Speed
Heading
(0 to 999999 seconds)
(0-255)
( degrees 0-359)
Sets the speed of the robot on a scale from 0 to 255. Each robot translates the value differently into a real world speed. For example, Ollie is almost three times faster than Sphero! Speed (0-255)
Sets the direction at which the robot rolls. 0 degrees heading is straight forward, 90 degrees is a right turn, 270 is a left turn, and 180 degrees is straight backwards. Heading (degrees 0-359)
Sets the speed to zero on the robot and halts all movement. The rest of the program continues to run as normal.    
Turns robot stabilization system on or off for a duration. Stabilization is normally on and enables the robot’s upright position. When it is turned off the robot will not remain upright, enabling unstable behaviours like jumping or wobbling. Boolean - used for creating true/false statements. On/Off
Controls the power of the left and right motors independently on a scale from 0 to 4095. If you set both motors to full power the robot will jump off the ground. Robot stabilization is disabled for the duration of this unpredictable movement is possible. Left Motor Power Right Motor Power Duration

(-4095 to 4095)

(-4095 to 4095)

(0 to 999999 seconds)

Spins the robot for a given number of degrees over time. 360 degrees is a single revolution.

Degrees

Duration

(-999999 to 999999) (0 to 999999 seconds)
Changes the colour of the main LED lights. Set this using the colour wheel and brightness slider, or the exact RGB (red, green, blue) values on a scale from 0 – 255. Red
Green
Blue
Brightness

(0-255)
(0-255)
(0-255)

Sets the brightness of the back aiming LED (which is limited to blue only) on a scale from 0 to 255.

 

Brightness

 

(0-255)

Changes from one colour to another over specific time period, measured in seconds. “From” Colour
Red
Green
Blue
Brightness
Duration “To” Colour
Red
Green
Blue
Brightness

(0-255)
(0-255)
(0-255)

(0-999999 seconds)
(0-255)
(0-255)
(0-255)
Blinks the main LED lights for a period (time that includes light ON and OFF) for a count of cycles. A short period will produce a fast blink whereas a long period will produce a slow blink. Red
Green
Blue
Brightness
Period
Count
(0-255)
(0-255)
(0-255)

(0-999999)
(0-65535)
Controls      
Continues to run active blocks until a given amount of time passes. Delay (0-999999 seconds)
Repeats the bocks contained within it for the number of loops specified, with a minimum of 1. Count (0-65535)
Repeats the blocks contained within it forever.    
Performs the blocks contained within it until a condition is met. (Condition) (true or false)
Performs the blocks contained within it only if the given condition is true. (Condition) (true or false)
Performs the blocks contained within “then” if the given condition is true. Otherwise performs the alternate “else” blocks instead. (Condition) (true or false)
Stops all code on the canvas from executing on the robot, ending the program.    
Operators      
Assigns a value to a given sensor or variable. Set is the only block in the Operators section. All other tools are to be used within the Set block.    
Adds two values together. Value
Value
(-999999-999999)
(-999999-999999)
Subtracts one value from the other. Value Value Value
Value
(-999999-999999)
(-999999-999999)
Multiplies two values together. Value
Value
(-999999-999999)
(-999999-999999)
Divides one value from the other. Value
Value
(-999999-999999)
(-999999-999999)
Multiplies a value within itself a specific number of times. Value
Value
(-999999-999999)
(-999999-999999)
Returns the square root of a value. Value (-999999-999999)
Rounds a value to the nearest integer value. Value (-999999-999999)
Rounds a value down to the nearest integer value. Value (-999999-999999)
Rounds a value up to the nearest integer value. Value (-999999-999999)
Returns the magnitude of a value, removing its sign. Value (-999999-999999)
Returns +1 for positive values, -1 for negative values, and 0 for zero. Value (-999999-999999)
Returns the remainder after division of one value by another. Value (-999999-999999)
(-999999-999999)
Returns the lesser of two values. Use this to set a lower bound on a value. Value
Value
(-999999-999999)
(-999999-999999)
Returns the greater of two values. Use this to set an upper bound on a value. Value
Value
(-999999-999999)
(-999999-999999)
Generates a random value within the given minimum and maximum. Minimum Value Maximum Value (-999999-999999)
(-999999-999999)
Comparators Comparators are used with conditions.    
Requires the left value to be equal to the right value for this condition to be true. Value
Value
(-999999-999999)
(-999999-999999)
Requires the left value to be unequal to the right value for this condition to be true. Value
Value
(-999999-999999)
(-999999-999999)
Requires the left value to be less than the right value for this condition to be true. Value
Value
(-999999-999999)
(-999999-999999)
Requires the left value to be less than or equal to the right value for this condition to be true. Value
Value
(-999999-999999)
(-999999-999999)
Requires the left value to be greater than the right value for this condition to be true. Value
Value
(-999999-999999)
(-999999-999999)
Requires the left value to be greater than or equal to the right value for this condition to be true. Value
Value
(-999999-999999)
(-999999-999999)
Requires the left and right comparisons to be true for this condition to be true. Value
Value
(-999999-999999)
(-999999-999999)
Requires the left or right comparison to be true for this condition to be true. Value
Value
(-999999-999999)
(-999999-999999)
Variables Variables – Create a variable that can be reused throughout a program to limit redundant logic. You can modify the value of a variable by using a set operator block.

 
Create a variable that can be reused throughout a program to limit redundant logic. Variable Name Default Value (-999999-999999)
Shows “Delete” and “Edit” icons over existing variables.    
Allows user to edit variable name and default value.    
Deletes variable.    
Sensors Description Reading
  Sensors – Sensors are variables that tell the program what is going on in the Sphero. These can be used in comparators and with the Set operator.  
Reads or writes the real-time heading measurement as a value. Heading is the direction in which the robot rolls. 0 degrees heading is straight forward, 90 degrees is a right turn, 270 is a left turn, and 180 degrees is straight back.  
Location of the robot in relation to the origin at the start of the program in meters. This sensor reads the location to use as a value. X-Axis - X location of the robot in relation to the origin at the start of the program. X-axis positive is right of the robot at 90 degrees. This sensor reads the X-axis displacement to use as a value. Y-Axis - Y location of the robot in relation to the origin at the start of the program. Y-axis positive is straight in front of robot at 0 degrees. This sensor reads the Y-axis displacement to use as a value.
Reads or writes the real-time speed measurement as a value. Speed is how fast the robot rolls on a scale from 0 to 255.  
Estimated speed along a given axis in meters per second. This sensor reads the speed to use as a value. Combined - Estimated speed in meters per second of the combined X and Y axis velocity. This sensor reads the speed to use as a value. X-Axis - Estimated speed along the X-axis in meters per second. This sensor reads the X- axis speed to use as a value. Y-Axis - Estimated speed along the Y-axis in meters per second. This sensor reads the Y- axis speed to use as a value.
The tilt angle of the robot along a given axis. This sensor reads the angle to use as a value. Pitch - The forward or backward tilt angle of the robot on a scale from -180 to 180 degrees; imagine an airplane ascending or descending. This sensor reads the pitch angle to use as a value. Roll - The left or right tilt angle of the robot on a scale from -90 to 90 degrees; imagine an airplane rolling to the left or right. This sensor reads the roll angle to use as a value. Yaw – The spin angle of the robot on a scale from -180 to 180 degrees; imagine a plane turning left or right. This sensor reads the yaw angle to use as a value.
Motion detection on a scale from -8 to 8 G’s. This sensor reads the acceleration along a given axis to use as a value. Combined - Total acceleration of the robot combining all three axes on a scale of 0 to 14 G’s. This sensor reads the total acceleration to use as a value. X-Axis - Lateral motion detection on a scale of -8 to 8 G’s. This sensor reads the X-axis accelerometer reading to use as a value. Y-Axis - Forward motion detection on a scale of -8 to 8 G’s. This sensor reads the Y-axis accelerometer reading to use as a value. Z-Axis - Vertical motion detection on a scale of -8 to 8 G’s. This sensor reads the Z-axis accelerometer reading to use as a value.
The rate of rotation around a given axis in degrees per second with a range of -2,000 to 2,000. This sensor reads the rate to use as a value. Pitch - The forward or backward tilt angle of the robot on a scale from -180 to 180 degrees; imagine an airplane ascending or descending. This sensor reads the pitch angle to use as a value. Roll - The left or right tilt angle of the robot on a scale from -90 to 90 degrees; imagine an airplane rolling to the left or right. This sensor reads the roll angle to use as a value. Yaw – The spin angle of the robot on a scale from -180 to 180 degrees; imagine a plane turning left or right. This sensor reads the yaw angle to use as a value.
Acceleration up and down on a scale of -8 to 8 G’s, regardless of the robot’s orientation. This sensor reads the vertical acceleration to use as a value.  
Colour channel of the main LED lights on a scale from 0 – 255. This sensor writes the red, green or blue channel of the colour

Red - Red channel of the main LED lights on a scale from 0 – 255. This sensor writes the red channel of the colour Green - Green channel of the main LED lights on a scale from 0 – 255. This sensor writes the green-channel of the colour

Blue - Blue channel of the main LED lights on a scale from 0 – 255. This sensor writes the blue channel of the colour channel of the colour

Events Description
Blocks within this event activate when “Start” is pressed in the Lightning Lab app.
Conditional logic performed when the robot collides with an object.
Conditional logic performed when the robot falls through the air, defined by an accelerometer reading of <0.1 G for a duration of >= 0.1 seconds. Remember that 1 G is resting.
Conditional logic performed when the robot lands after an “On Freefall” event.
Conditional logic performed when the robot reaches the upper limit of rotational velocity. Gyro max can be triggered by spinning the robot extremely fast.
Functions    
Tool Description Variable
Creates a new Function. Opens “Function” screen which allows user to define parameters and add blocks of code. Function Name.
Shows “Delete” and “Edit” icons over existing functions.  
Allows user to edit function.  
Deletes function  
Creates a new Parameter. Parameter Name.
Shows “Delete” and “Edit” icons over existing parameters.  
Allows user to rename the parameter.  
Deletes the Parameter.  
Sphero Coding Devices Rules of Use The Code Blocks Exercises to Complete Advanced Programming Guide Home