BlocklyProp Block Reference for the Scribbler 3 Robot.
Open the BlocklyProp online programming tool. [1]
Need HELP? If you get stuck, contact Parallax Tech Support: email support@parallax.com. The BlocklyProp FAQ for Schools [2] may also be of help installing BlocklyProp.
The CONTROL blocks in BlocklyProp are used to build the structure of a blockly program. Use these blocks to add a loop, if...do statement, wait time, or program comment.
The loop forever block creates a loop that, depending on the option chosen in the menu, can do one of four functions - repeat forever, __ x times, until __, or while __. With the exception of repeat forever, each of the other options requires a condition to be added that indicates when the loop should end.
The loop item block creates a loop that repeats a certain number of times, starting with the from__ value and ending with the end__ value. To take larger steps between the start and end values, increase the by__ value.
Caution: If you are using a variable you already created for the loop item, this block will reset it to be equal to the from__ value, and it will keep changing the value of the variable each time it loops.
The exit loop block will exit a loop and proceed to the next block in the program.
The if...do block is for decision-making: if the condition inserted at right is true, the enclosed code in the do section will execute. If the condition is not true, the do section will be skipped over and not executed.
The if...do block is a mutating block, indicated by the gear which you can click. It allows the block to include multiple “else” and “else if” conditions. If the first condition is not true, its enclosed code will be skipped and the next else if or else conditions will be evaluated and executed if true, before exiting the outer block.
The switch...case block looks at the value of the item attached at switch, jumps down to its matching case, and executes the code enclosed in that case's do section. Click the gear to add additional case conditions. The break option is selected by default. If it is not selected, the program will continue to execute the code enclosed by the cases below it until it runs into a checked break. If a default is provided, it will execute the code enclosed in the default's do section if none of the other cases match switch's value.
The wait block forces the program to halt and wait for a specified amount of time before continuing to the next block.
The add comment block will add a comment or note to the program. This block does not affect the way the program runs. It is simply a way to write a note in the program to help others understand the program. Blank separator is another option from the drop-down menu on the block:
Blank separator turns the block into a blank white block. Just like adding a comment, using a blank separator does not affect your program. You can use it to create a visual separation between parts of your program. The block can be changed back to an add comment block by clicking on the triangle and selecting comment.
The VARIABLES blocks allow you to create and use variables in your programs.
The set variable block allows you to create a variable and assigns it an initial value. You can create multiple variables in your program.
Once you create a variable, using this block again within your program will allow you to change the value of any variable you have created. The program will then use the new value for the rest of the program or until the value is changed again (see top image for example).
Your variable will also be accessible from any other block that has an item drop-down menu, such as the use variable block below.
The use variable block provides the value of the variable selected in the drop-down menu when inserted into other blocks.
The ARRAYS blocks allow you to create and use arrays in your programs.
The array initialize block allows you to create an array variable and define the number of elements in your array.
Now, your array will be accessible from any other array block that has the same name, such as the array get element block below.
The array fill block allows you to set multiple elements in your array using a comma-separated list of numbers. All numbers must be integers. Any decimal values will be truncated, and if there are more values typed in than there are elements in the array, it will only fill the available elements. The elements are always filled in order starting with element 0 (zero).
The array get element block provides the value of the specified element. You can specify the element to retrieve with either a number value block or any other block that provides a value, such as a get variable block.
The array set element block sets the element specified by the first inserted block to the value specified by the second inserted block so that the two are equal.
The array clear block sets all of the elements in your array to 0 (zero).
The FUNCTIONS blocks in BlocklyProp are used to create or use program functions.
The define function block is used to build a function that can be reused. This block (and the enclosed group of blocks it contains) are separate from the main program.
Once you have created a function, a run function block will be created for it and will appear in the FUNCTIONS menu.
The run function block runs the code inside of a define function block by the same name. In coding, this is referred to as "calling a function" or "making a function call." You must first create and name a function with a define function block to generate a run function block.
You can use a run function by placing a run function block into your main program. This block can be used multiple times in the same program.
The MATH block category contains value blocks, comparison blocks, and mathematical operation blocks.
The number value block is a value that is usually placed in or attached to other blocks that are expecting a numeric value. You can type any numeric value into the block. Non-integers (fraction or decimal) will be truncated to integer values.
The true/false block provides a value of 1 (true) or 0 (false) depending on which is selected.
The random true/false block randomly chooses whether to return true (1) or false (0).
The random number block provides a random number between the first inserted low value and the second inserted high value. The first number must be smaller than the second number. If not in that order, the resulting random value may be unexpected, such as a number outside the range specified.
The math operation block performs a mathematical operation on the two inserted value blocks. Non-integer (fraction or decimal) results will be truncated to an integer. Select one of the following operations from the drop-down menu:
The highest/lowest block, when set to highest, provides the highest of the two values placed in the block, and when set to lowest, provides the lowest of the two values placed in the block.
The boolean comparison block performs a boolean comparison between the two inserted values and provides a 1 (true) or 0 (false) depending on which of the following options is selected:
The de/increment block increases (increment) or decreases (decrement) the variable attached to it by 1.
The not block performs the selected operation on the value attached and provides the result. The options are:
The compare values block compares two inserted values and provides a boolean value, 1 if the equation is true, and 0 if it is false. Choose the type of comparison from the dropdown menu:
The constrain value block limits the value of an item to between 0 and 100. Enter the desired minimum (lowest) and maximum (highest) values for an item in the text fields.
The advanced math block performs a trigonometric, exponential, or logarithmic function on the inserted values, and stores the result in a variable. Angles are in integer degrees, not radians. Options are:
Since Blockly is working only with integer math, the block requires you to begin with a multiplier (the first inserted value). Although you could use 1 here, larger numbers make this block more precise.
The inverse trig block performs an inverse trigonometric function. The angles that this block calculates and stores are in integer degrees, not radians. Options are:
Because inverse trigonometry operations usually are done on ratios (one number divided by another) this block requires you to input both the numerator and denominator of the ratio. If you need the inverse trig operation of a single number, use 1 as the denominator (the second number).
The SENSOR blocks are used to control and monitor the onboard sensors of the Scribbler 3 Robot.
This block category contains the following subcategories: LINE, OBSTACLE, LIGHT, STALL, SONY REMOTE, MICROPHONE, and BUTTON.
LINE category blocks monitor the IR sensors on the underside of the Scribbler 3 Robot.
The line sensor calibrate block, used at the very beginning of a line following program, helps the line following sensors determine how reflective the line and the background surface are. The Scribbler robot will spin in a complete circle - place it so that as it rotates, it can see both the line and the background. Once calibration has completed, it will store a "line threshold" value into the Scribbler's EEPROM memory for use by the detect line block.
The detect line block has 3 selectable conditions. When the S3 line sensors detect a condition matching the block conditions selected by the user, this block will execute any program blocks inside of it.
The first condition determines whether or not to provide a true (when "is" is selected) or false (when "is not" is selected) value when the conditions specified by the other two drop-down menus have been met.
The second condition determines what part of a line to try and detect, with the following options:
The third condition defines whether the S3 is looking for a black line on a white surface or a white line on a black surface.
The line sensor reading block returns the current line sensor reflection reading, a value between 0 and 100, for either the left or right line sensor depending on which is selected. Reflectivity depends on surface color; darker surfaces have less reflectivity (closer to 0), lighter surfaces have more (closer to 100).
This block has been deprecated. It will still work in programs that already include it, but it is not available for use in new programs. It may also appear orange, signifying that a newer block is available and should be used. It was replaced to provide more flexibility by allowing both if and else conditions when combined with the if...do block.
The functionality of this block can be recreated using a handful of other blocks. Most users will be able to combine the if...do block with the current detect line block:
For users who needed the functionality provided by the "was" and "was not" conditions, you can set up two variables to track the current and past values of the line sensor:
OBSTACLE blocks monitor the two IR LEDs (emitters) and receiver on the front of the Scribbler 3 Robot.
The detect obstacle block has 2 selectable conditions. If the obstacle sensor readings match the block conditions selected by the user, the detect obstacle block provides a value of true or false.
The first condition determines whether the block returns true (if the obstacle is detected) or false (if the obstacle is not detected).
The second condition determines what the obstacle sensor readings should be, with the following options:
This block has been deprecated. It will still work in programs that already contain it, but it is not available in new programs. It may also appear orange, signifying that it should be replaced as soon as possible. This block has been replaced to provide more flexibility by allowing both if and else conditions when combined with the if...do block.
The functionality of this block can be recreated using a handful of other blocks. Most users will be able to combine the if...do block with the current detect line block:
For users who needed the functionality provided by the "was" and "was not" conditions, you can set up two variables to track the current and past values of the line sensor:
LIGHT blocks monitor the three phototransistors on the top-front of the Scribbler 3 Robot.
The light sensed block has 2 selectable conditions. If the light sensor readings match the block conditions selected by the user, then the light sensed block provides a value of true or false.
The first condition determines whether the block returns true or false based on whether the most (brightest) or least (darkest) amount of light is detected by the individual light sensor specified by the second drop-down menu.
The second condition determines which individual light sensor (front, right, or left) is detecting the most or least amount of light.
The light sensor reading block returns the current light level value, between 0 and 100, from either the left, center, or right light sensor in the top front of the Scribbler robot (whichever has been selected by the user). The value increases as the brightness of the light increases.
This block has been deprecated. It will still work in programs that already contain it, but it is not available in new programs. It may also appear orange, signifying that it should be replaced as soon as possible. It was replaced to provide more flexibility by allowing both if and else conditions when combined with the if...do block.
The functionality of this block can be recreated using a handful of other blocks. Most users will be able to combine the if...do block with the current detect line block:
For users who needed the functionality provided by the "was" and "was not" conditions, you can set up two variables to track the current and past values of the line sensor:
The second condition determines what the light sensor readings should be, with the following options:
STALL blocks monitor the encoders within the Scribbler 3 Robot responsible for detecting tail wheel and drive wheel rotation.
The detect stall block allows for the detection of stalled drive wheels, a stalled tail wheel, or an overall stall condition ("stuck"). If the specified sensor/system stalls, the detect stall block provides a value of true (is) or false (is not).
The detect stall block needs to be used with the following tips in mind:
These blocks have been deprecated. They will still work in programs that already have them, but they are not available for new programs. They may also appear orange, signifying that they should be replaced as soon as possible. These blocks were replaced to provide more flexibility by allowing both if and else conditions when combined with the if...do block.
The functionality of the detect stall (old) block can be recreated using a handful of other blocks. Most users will be able to combine the if...do block with the current detect stall block:
For users who needed the functionality provided by the "was" and "was not" conditions, you can set up two variables to track the current and past values of the stall sensor:
BlocklyProp block reference for using a Sony protocol remote and infrared receiver with the S3 robot.
An IR receiver can detect bursts of infrared light sent by a remote controller (like that used for television), and then output a pattern of high/low signals to a Propeller I/O pin.
Configure your remote for Sony protocol, following its manufacturer instructions. If you purchased the Brightstar brand remote from Parallax (#020-00001), hold the Setup button until the light near it comes on. Enter 6-0-5 and the light should go off. Done!
The Sony Remote value block returns a value detected by the IR receiver that indicates which button on the remote is pressed. If no button press is detected, then this block provides a value of -1.
This block's drop-down menu selects the Propeller I/O pin connected to an infrared receiver. When using the S3 board type, the default option is the onboard IR sensor (which is connected to P20). However, the drop-down also gives the option of connecting to P0... P5 on the S3's Hacker Port.
The microphone block provides a value based on the loudness of any sounds it is detecting. The value of the block ranges from 0 (silence) to 100 (extremely loud).
The BUTTON block monitors the blue reset button on the top-rear of the Scribbler 3 robot.
The button sensor block monitors and returns the number of times (0-8) the Scribbler 3 reset button is pressed in succession.
The ACTIONS category contains blocks that control physical behavior or serial communication in the S3 robot and in sensors connected to the hacker port. With these blocks, you can control motors, LEDs, standard servos, terminal communication, sound, or reset your Scribbler Robot to factory settings.
This block category contains the following subcategories: MOTORS, SOUND, LEDs, COMMUNICATE, RESET.
DRIVE blocks control the Scribbler 3 Robot's drive wheels and standard servos connected via P0-P5 on the exposed hacker port.
The drive block runs the Scribbler robot motors at a direction and speed determined by the user. The Scribbler robot will continue running the motors while also running block commands until the stop driving block command is used.
The rotate block rotates the Scribbler robot in place, in either direction, to an angle and at a top speed determined by the user. The angle, from 1 to 359 degrees, can be typed in or selected from a drop-down angle selector. The Scribbler robot will not run the next block command until the Scribbler robot stops moving.
The stop driving block immediately disables the Scribbler robot motors.
The drive speed block sets the left and right motor speeds as percentages of the top speed. Negative values are for backward travel, positive values for forward travel. When a value is outside of the -100 to 100 percent range, the block will use the closest value, either -100 or 100 percent. If a duration is specified, in milliseconds, the Scribbler robot will not run the next block command until the Scribbler robot stops moving. If the duration is over the maximum range of 65,535 milliseconds, then the block will use a duration of 65,535 milliseconds. If the duration is either unspecified, at the default of zero, out of range, or in the negative, then the Scribbler robot will continue running block commands while running the motors, until the stop driving command is used.
The drive distance block moves the left and right motors to each travel a distance, in units of inches, tenths of an inch, centimeters, millimeters, or encoder counts. Negative values are for backward travel, positive values for forward travel. If given different distances, then the motor traveling further will run at the specified speed, and the other will run at a slower speed so that both motors will stop at the same time. The speed is given as a percent of the maximum capable speed, in a range of 1 to 100 percent. The distance range is displayed next to the unit, and changes with the unit. If a speed or distance value is outside of the valid range, the block will use the closest valid value. The Scribbler robot will not run the next block command until the motors stop moving.
The drive to block moves the scribbler to a new XY coordinate based on the X and Y changes entered. The Scribbler robot begins keeping track of where it is in an imaginary coordinate grid (where X is left/right, and Y is forward/backward relative to its starting position) when it begins its program. As long as all the motions in the program are drive distance or drive to blocks and there are no arcs or curves, the Scribbler robot will be able to accurately position and orient itself on the imaginary grid. The X and Y axes of the imaginary grid are established at the beginning of the program. The movement amounts entered into the block refer to how far the robot should move, not what coordinates to move to.
When the drive to block is used, the Scribbler will first pivot (turn) and point itself in the direction it should move, and then it will move to the new coordiate. The total distance that it travels is:
The drive a turn block rotates the Scribbler robot around a point, with a radius that is a specified distance to the side of the center of the robot, in units of inches, tenths of an inch, centimeters, millimeters, or encoder counts. The radius can be 0, to rotate in place, or it can be positive, to rotate around a point to the right of the Scribbler robot, or negative, to rotate around a point to the left of the Scribbler robot.
The angle to rotate can be negative, to drive in reverse, or positive, to drive forward. If the radius is zero, the Scribbler robot will spin clockwise with a positive angle and counterclockwise with a negative angle. The angle value is valid from -1,080 to 1,080, while the radius value range is displayed next to the unit, and changes with the unit. If a speed or distance value is outside of the valid range, then the block will use the closest valid value. The Scribbler robot will not run the next block command until the motors stop moving.
SOUND blocks activate and control the Scribbler 3 Robot built-in piezospeaker.
The play note block plays a tone, using a note, frequency, and volume determined by the user. The Scribbler robot will not run the next block command until the note finishes playing.
The play tone block plays one or two tones for a specified period. Both the duration and frequency are set by the user. Either frequency can be left at the default 0 Hz, for silence, or set up to 10,000 Hz. The duration can be set between zero and 8,000 ms. For values outside of the valid 0 to 10,000 Hz and 1 to 8,000 ms ranges, the block will use the closest value that is within range. The Scribbler robot will not run the next block command until the note finishes playing.
LEDs blocks control the Scribbler 3 Robot's three indicator LEDs.
The change LEDs block allows control over the 3 indicator LEDs on the S3 shell. Each LED can be set to off, green, red, or amber. The checkmarks (toggled on by default) allow the user to change LED states individually; any unchecked LED will not change from its current state when the block is executed.
COMMUNICATE blocks allow serial communication between the S3 Robot's Propeller microcontroller and the BlocklyProp terminal window and/or an XBee/WX radio/wifi module if installed in the Scribbler 3 robot. Because the terminal output and radio/wifi module socket are connected, these blocks send and receive from either or both simultaneously.
The send message block sends text to an attached serial device, either a USB cable for a terminal, or a wireless module mounted inside the Scribbler robot.
The send number block sends a number, in the form of text, to an attached serial device, either a USB cable for a terminal or a wireless module mounted inside the Scribbler robot. The number must be in the valid range of -2,147,483,648 to 2,147,483,647. If a number is outside of the valid range, the result will be indeterminate.
The send character block sends a number, in the form of a single character, to an attached serial device, either a USB cable for a terminal or a wireless module mounted inside the Scribbler robot. The number must be in the valid range of 0 to 255. If a number is outside of this range, the block will use the closest valid value.
The send command block sends a control character, determined by the user, to an attached serial device, either a USB cable for a terminal or a wireless module mounted inside the Scribbler robot.
The receive character block receives a character, in the form of a number, from an attached serial device, either a USB cable for a terminal or a wireless module mounted inside the Scribbler robot. If the Scribbler robot has received a character, the number will be in the valid range of 0 to 255. If the Scribbler robot has not received any characters, the number will be outside of the valid 0 to 255 range.
This block has been deprecated. It will continue to work in programs that are already using it. It is recommended that you find another means for positioning the cursor in the terminal, such as clearing the screen, using spaces, backspaces, and/or carriage returns.
The set cursor position block sends control characters that move a terminal cursor to a column and row, determined by the user, to an attached serial device, either a USB cable for a terminal or a wireless module mounted inside the Scribbler robot.
The RESET category contains a block that allows you to restore Factory Default settings (the 8 demo programs) to your Scribbler 3 Robot.
The factory reset block restores the original factory installed demo program onto the Scribbler robot. Use this block on its own with no other blocks in the program.
This block must be loaded to EEPROM.
The HACKER PORT category contains blocks that interact with devices connect to the S3 robot's hacker port. With these blocks, you can control individual hackerport pins, servos, and sensors.
This block category contains the following subcategories: SENSORS, PINS, SERVO.
The SENSORS category has a block for interacting with a peripheral PING))) Ultrasonic Distance Sensor, connected through the Hacker Port (on P0 - P5).
The Ping))) distance block returns the distance measurement between the sensor and an object located within its detection range (in inches or centimeters - set by the drop-down menu). The PING))) sensor can detect an object located between 1 inch (3 cm) and 125 inches (315 cm) away. The PING))) sensor must be connected to a digital hacker port location (P0 - P5) matching the selection on the block.
BlocklyProp blocks for interacting with the Propeller I/O pins available from the S3 Hacker Port.
The make PIN block sets the function and state of a Hacker Port digital I/O pin.
Select a Hacker Port digital I/O pin, P0 to P5.
Set the function and state with the second drop-down:
The check PIN block returns a 1 if the digital I/O pin selected is high and returns a 0 (zero) if the pin is low. It is used to read the pin as an input or to check what it was set to previously as an output.
The check analog PIN block returns the voltage (in volt-100ths) sensed by the specified analog Hacker Port I/O pin (A0 or A1)
The servo rotate block sends a signal to rotate a standard servo to the angle determined by the user. The servo must be connected to a digital Hacker Port location (P0 through P5) matching the selection on the block. The block accepts a range of 0 to 180 degrees, although some servos may be limited to 45 to 135 degrees. If an angle is out of range, the block will use the closest valid value. The Scribbler Robot will continue sending the servo signal while running block commands until the disable servo is used.
The servo disable block immediately disables the servo signal on the digital Hacker Port location (P0 through P5) determined by the user.
Links
[1] http://blockly.parallax.com
[2] https://learn.parallax.com/support/download/1741/blocklyprop-faq-schools
[3] http://learn.parallax.com/support/reference/propeller-blocklyprop-block-reference/about-naming-things