Types of blocks

There are a total ofĀ nineĀ block types in CB. Each of them is represented by their own color. Every block translates to code, which is then compiled and uploaded to the phone, just like on every Arduino based platform.


Pressing on every block type will open a section from which you can drag-and-drop those blocks into the drawing area.

Also, pressing onĀ ā€˜Moreā€™Ā will open even more blocks that are not so commonly used.

There are two main functions of every Arduino code ā€“Ā void setup()Ā andĀ void loop().

Everything that goes into theĀ voidĀ setup()Ā the function will run only once. It is primarily used for starting the software, initializing and declaring variables and running functions that only have to run once (ex. Intro screen in a video game).

TheĀ void loop()Ā is where everything else takes place. It basically runs every bit of code inside it over and over again (speed depends on the device ā€“ just imagine itā€™s ultra-fast!). It should pretty much follow the refresh rate of the screen and make the program do things accordingly.

Every block you place automatically goes into theĀ void loop()Ā function.

If you wish to put something in theĀ void setup(), you have to drag the main block fromĀ FunctionsĀ and place your blocks inside as you wish, but more on that a little bit later.

Elliptical blocks

Elliptical blocksĀ represent variables. Whether weā€™re talking about integers, strings or other variable types (other than boolean), they can all be recognized by the same shape.

Also, larger blocks that have elliptical shape return either integer or float values.

random image

When ever you find circular ā€œholesā€ inside some blocks, that is the place where variables can be inserted. Itā€™s most commonly found inĀ comparisonĀ orĀ actionĀ blocks.

Triangular blocks

Boolean variables are represented by triangular blocks.

Both variables (true and false), as well as functions that return boolean values, have the same shape.

random image

Regardless of color, each of these blocks returns either true or false.

Triangular ā€œholesā€ require boolean blocks to be inserted.

random image

Building blocks

Everything else is basically a building block. Those are functions that have no return value (they returnĀ null). Both elliptical and triangular blocks first have to be placed inside of the building blocks in order to act as part of the program.

They have a specific ā€œpuzzleā€ shape and can be stacked inside each other.

random image

The mainĀ building blockĀ is located inside theĀ ā€˜Functionsā€™Ā section.

It basically gives you two main building blocks sections.

Everything that is placed insideĀ Arduino run firstĀ goes intoĀ void setup()Ā and everything that is placed insideĀ Arduino loop foreverĀ goes into aĀ void loop().

random image

Inserting blocks

Now, this is the main part.

The whole point of blocks-like IDE is connecting blocks and placingĀ them one inside another.

It is all done by simpleĀ drag-and-dropĀ action.

Here is an example of a program that will set the variableĀ VarĀ toĀ 1 and then increase that variable while it is smaller than 10.

At the end of the program,Ā Var will be 10.

This is just a simple example and block-building will be further explained in the following chapters.

random image