Anda di halaman 1dari 3

Programming Block Hints

Actions control the robot's movement and lights. The robot moves with three basic
instructions: speed, delay and heading. For example, if speed = 60, delay = 3s and
Actions heading = 0deg, the robot would roll forward for 3 seconds at a moderate speed.
Roll Combines heading, speed and time variables to make the robot roll.
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
Set Speed Sphero!
Sets the direction at which the robot rolls. 0 degrees heading is straight forward, 90
Set heading degrees is a right turn, 270 is a left turn, and 180 degrees is straight backward.
Sets the speed to zero on the robot and halts all movement. The rest of the program
Stop continues to run as normal.
Turns robot stabalization system on or off for a duration. Stabalization is normally on
and enables the robot's upright position. When it is turned off the robot will not remain
Stabilization upright, enabling unstable behaviors like jumping or wobbling.
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
Raw Motor is disabled for the duration of this block unpredictable movement is possible.
Spins the robot for a given number of degrees over time. 360 degrees is a single
Spin revolution.
Changes the color of the main LED lights. Set this using the color wheel and brightness
Set Color slider, or the exact RGB (red, green, blue) values on a scale of 0 - 255.
Sets the brightness of the back aiming LED (which is limited to blue only) on a scale
Back LED from 0 to 255.
Fade Changes from one color to another over specific time period, measured in seconds.
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
Strobe slow blink.
Controls change the flow of your program and allow conditional or branching logic. For
Controls example, "if speed > 20, then change LED lights to red."
Delay Continues to run active blocks until a given amount of time passes.
Repeats the blocks contained within it for the number of loops specified, with a minimum
Loop of 1.
Loop Forever Repeats the blocks contained within it forever.
Loop Until Performs the blocks contained within it until a condition is met.
If Then Performs the blocks contained within it only if the given condition is true.
Performs the blocks contained within "then" if the given condition is true. Otherwise
If Then Else performs the alternate "else" blocks instead.
Exit Program Stops all code on the canvas from executing on the robot, ending your program.
Operators are mathematical operations to modify values or create new ones. Several
operators can be chained together to create complex logic within a single block. For
Operators example, "heading = heading + 180" adds 180 degrees to the current heading angle.
Set Assigns a value to a given sensor or variable.
Add (+) Adds two values together.
Subtract (-) Subtracts one value from the other.
Multiply (*) Multiplies two values together.
Divide (/) Divides one value from the other.
Exponent Multiplies a value with itself a specified number of times.
Sqrt (Square Root) Returns the square root of a value.
Round Rounds a value to the nearest integer value.
Floor Rounds a value down to the nearest integer value.
Ceiling Rounds a value up to the nearest integer value.
Abs (Absolute Value) Returns the magnitude of a value, removing its sign.
Sign Returns +1 for positive values, -1 for negative values, and 0 for zero.
Mod (Modulo) Returns the remainder after division of one value by another.
Min (Minimum Value) Returns the lesser of two values. Use this to set a lower bound on a value.
Max (Maximum Value) Returns the greater of two values. Use this to set an upper bound on a value.
Random Generates a random value within the given minimum and maximum.
Comparators can be added to blocks to compare two values and create conditional
logic. For example, "loop strobe LED until heading >= 270" executes strobe blinking until
Comparators the heading reaches 270 degrees.
Equal (==) Requires the left value to be equal to the right value for this condition to be true.
Not Equal (!=) Requires the left value to be unequal to the right value for this condition to be true.
Less Than (<) Requires the left value to be less than the right value for this condition to be true.
Requires the left value to be less than or equal to the right value for this condition to be
Less Than Or Equal (<=) true.
Greater Than (>) Requires the left value to be greater than the right value for this condition to be true.
Requires the left value to be greater than or equal to the right value for this condition to
Greater Than Or Equal (>=) be true.
And Requires all statements within to be true for this condition to be true.
Or Requires any statement within to be true for this condition to be true.
A variable defines a value that is used throughout a program to limit redundant logic.
Use a set operator to change the value of a variable anywhere in your program. For
example, create a loop that evaluates your variable such as "loop until myVar == 1."
Then add "set myVar = 1" to an On Collision event so that a collision forces the loop to
Variables exit.
Read (R) and write (W) values from the robot's sensors. Some sensors can also be
modified using the Set operator. For example, "if x-axis accelerometer > 3G, then set
Sensors heading = 90."
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,
Heading 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
Location sensor reads the location to use as a value.
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
Location / X-Axis a value.
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
Location / Y-Axis use as a value.
Reads or writes the real-time speed measurement as a value. Speed is how fast the
Speed robots rolls on a scale from 0 to 255.
Estimated speed along a given axis in meters per second. This sensor reads the speed
Velocity to use as a value.
Estimated speed in meters per second of the combined X and Y axis velocity. This
Velocity / Combined sensor reads the speed to use as a value.
Estimated speed along the X-axis in meters per second. This sensor reads the X-axis
Velocity / X-Axis speed to use as a value.
Estimated speed along the Y-axis in meters per second. This sensor reads the Y-axis
Velocity / 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
Orientation value.
The spin angle of the robot on a scale from -180 to 180 degrees; imagine a plane
Orientation / Yaw turning left or right. This sensor reads the yaw angle to use as a value.
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
Orientation / Pitch as a value.
The left or right tilt angle of the robot on a scale from -90 to 90 degrees; imagine an
Orientation / Roll airplane rolling to the left or right. This sensor reads the roll angle to use as a value.
Motion detection on a scale of -8 to 8 G's. This sensor reads the acceleration along a
Accelerometer given axis to use as a value.
Total acceleration of the robot combining all three axes on a scale of 0 to 14 G's. This
Accelerometer / Combined sensor reads the total acceleration to use as a value.
Lateral motion detection on a scale of -8 to 8 G's. This sensor reads the X-axis
Accelerometer / X-Axis accelerometer reading to use as a value.
Forward motion detection on a scale of -8 to 8 G's. This sensor reads the Y-axis
Accelerometer / Y-Axis accelerometer reading to use as a value.
Vertical motion detection on a scale of -8 to 8 G's. This sensor reads the Z-axis
Accelerometer / Z-Axis accelerometer reading to use as a value.
The rate of rotation around a given axis in degrees per second within a range of -2,000
Gyroscope to 2,000. This sensor reads the rate to use as a value.
The spin rate of the robot on a scale from -2,000 to 2,000 degrees per second; imagine
Gyroscope / Yaw a plane turning left or right. This sensor gets the yaw rate to use as a value.
The rate of forward or backward tilt of the robot on a scale from -2,000 to 2,000 degrees
per second; imagine an airplane ascending or descending. This sensor reads the pitch
Gyroscope / Pitch rate to use as a value.
The rate of left or right tilt of the robot on a scale from -2,000 to 2,000 degrees per
second; imagine an airplane rolling to the left or right. This sensor gets the roll rate to
Gyroscope / Roll use as a value.
Acceleration up and down on a scale of -8 to 8 G's, regardless of the robot's orientation.
Vertical Acceleration This sensor reads the vertical acceleration to use as a value.
Color channel of the main LED lights on a scale from 0 - 255. This sensor writes the red,
Color green or blue channel of the color.
Red channel of the main LED lights on a scale from 0 - 255. This sensor writes the red
Color / Red channel of the color.
Green channel of the main LED lights on a scale from 0 - 255. This sensor writes the
Color / Green green channel of the color.
Blue channel of the main LED lights on a scale from 0 - 255. This sensor writes the
Color / Blue green channel of the color.
Conditional logic performed when a predefined robot function occurs. For example, "on
Events collision, change LED lights to green." Blocks with a delay cannot be added to an event.
On Collision 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
On Freefall resting.
On Land Conditional logic performed when the robot lands after an onFreefall event.
Conditional logic performed when the robot reaches the upper limit of rotational velocity.
On Gyro Max Gyromax can be triggered by spinning the robot extremely fast.
Functions contain a group of blocks that can be reused throughout your program. Add
parameters to specify different input values for your function. Remember to drag the
Functions function onto the canvas to use it.
Create a parameter that can be inputted into your function to change the logic.
Parameters Parameters can be used within a function the same way as a variable is used.

Anda mungkin juga menyukai