Welcome to the BlocklyProp Tips & Tricks for the Scribbler 3 Robot. Study these short resources to learn a little something more about BlocklyProp blocks or how to use some of the basic BlocklyProp features.
Refer back to these pages as often as you like. They will likely come in handy as your BlocklyProp programs progress in length and complexity.
Every once in a while a note of explanation to another code user or to yourself is helpful. Comments or notes are used by coders to leave instructions, reminders, and information inside their code – for themselves or for those who might also use their work. This is done in BlocklyProp with the note block.
Comments are notes about your code that help explain to other people what your code is doing. Also, it is good to leave comments as notes to yourself about what you were doing in case you need a reminder days (or months or years) later. The process of leaving notes or comments in your code is referred to as "documenting your code".
You can help make your code self-documenting by picking variable and constant names that help make the program more self-explanatory. In a visual program language like Blockly, code often explains itself.
Why might you leave a note in your code?
Know that coders have differing ideas about comments - some prefer very few comments or even none at all, others prefer thorough documentation.
Remember that with BlocklyProp the code visually explains, so less is more!
This is the add comment block. It is found in the CONTROL category:
In addition, blank separator can be chosen from the dropdown menu on the block:
The blank separator option turns the block into a blank white block. Just like adding a comment, using a blank separator has no effect on your program. You can use it to create 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.
In the example below, the coder named his program, recorded the date it was written, and listed himself as the author.
The purpose of such a comment might be so that this info could be recorded in a screen captured image of the code. Use comments in your BlocklyProp programs when they serve a specific purpose for you or for someone else. Otherwise, they can clutter your code and be more confusing than helpful.
Note: The add comment/blank separator block has no effect in your code. You can place them anywhere within your program that you need to make a note and it will not change your program's behavior in any way.
Special thanks to Parallax friend Whit Stodghill for his assistance in writing, editing, and testing material for these S3 tutorials.
One of the best ways to learn about all the features of BlocklyProp is allowing yourself time to explore and be curious.
For example, look at a block from the MATH category: the math operation block. You can see that it allows the user to input a value, variable, or test into the block to create a complete block command that has an output. In this block the input is “inline”, meaning the block reads in-a-line from left to right.
Presto! The block changed shape, transforming from inline input to external input.
Take a look at how the example block changed. You can see that they do the same thing, but format is different. The shape of the block is merely a preference. You can re-shape these blocks to suit your personal preference, or to create narrower programs if you need to take screencaptures or work from a minimized window.
Like it better the other way? No problem. Right click again and the menu reappears with the choices. This time you will see "Inline Inputs" instead and, when you select that option, you can go right back to the original block format you started with.
BlocklyProp blocks are created using the open source tools from Google’s Blockly resources. They can be created using Blockly with a tool called the Block Factory. You can give it a try anytime – there are even videos to show you how! Visit the Block Factory here [1].
As mentioned in the last section, you might need to make your program smaller in size. This can be for any number of reasons, but the important thing to note is that there is another way to shrink the physical dimensions of your program blocks: Collapse Block. This feature is explained later in these tutorials when you start to see large, complex programs, but it's worth mentioning here as well.
Blocks, such as the math operation block you've been working with, can have inline input fields that require you to nest other blocks inside. If those other blocks are wide, then you can start to see programs extend greatly in a horizontal direction. This can make it difficult to see or read your entire program without scrolling or resizing windows. Collapsing a block with other blocks inside of it will automatically collapse those other blocks too.
Look how small it became. To change it back, right-click on the block again and choose "Expand Block".
This feature will be discussed again later on, but keep in mind that it is there to simplify the appearance of your program. No information is lost when a block is collapsed (your program will still run the same), but some information is hidden to reduce its physical size.
Make a mess? Just drag it to the trash can or choose "Delete Block" from the right-click menu. Have fun!
Special thanks to Parallax friend Whit Stodghill for his assistance in writing, editing, and testing material for these S3 tutorials.
Perhaps no block in BlocklyProp has more programming power per pixel than the factory restore block. You can find it in the ACTIONS > RESET category.
It looks like this:
Notice that this block has no connecting tabs. That is because it is meant to be used alone. Its purpose is simple: to restore the factory demo program that came pre-loaded on your new S3 robot. These demo programs are designed to show off the capabilities of the S3, right out of the box.
One side has product, safety, and other information. The other side shows all the demonstration programs from the factory. Each different demo is accessed by pressing the reset button the specified number of times, and they are meant to showcase one or more of the S3’s sensors or abilities.
This factory program is probably the largest and most complex program your S3 will ever load to EEPROM and run. It takes advantage of every sensor and, except the Hacker Port, most every bit of hardware that is built into the powerful S3 robot. This one block restores all of that original code in one simple step.
Every time you write and send a program to the S3, this demo is replaced by your new code. To make your S3’s software factory fresh, simply follow the instructions in the next section. You can do this anytime you want.
To restore correctly, be sure the factory restore block is the only block in your workspace.
That’s all there is to it. You have now restored the S3’s factory demo code. See the S3 Info Poster for complete features.
Special thanks to Parallax friend Whit Stodghill for his assistance in writing, editing, and testing material for these S3 tutorials.
Links
[1] https://blockly-demo.appspot.com/static/demos/blockfactory/index.html
[2] https://www.parallax.com/downloads/scribbler-s3-robot-info-poster