In Blockly you have the possibility to perform various mathematical operations. You can calculate numbers, create random numbers and distribute values to another value range.

Calculating numbers

In Blockly you can perform various mathematical calculations. The following blocks are available:

/images/2020-04-08-blockly-mathematik/blockly-mathematik-1-en.svg - Logo
/images/2020-04-08-blockly-mathematik/blockly-mathematik-2-en.svg - Logo
/images/2020-04-08-blockly-mathematik/blockly-mathematik-3-en.svg - Logo
/images/2020-04-08-blockly-mathematik/blockly-mathematik-4-en.svg - Logo
/images/2020-04-08-blockly-mathematik/blockly-mathematik-5-en.svg - Logo
/images/2020-04-08-blockly-mathematik/blockly-mathematik-6-en.svg - Logo
/images/2020-04-08-blockly-mathematik/blockly-mathematik-7-en.svg - Logo
/images/2020-04-08-blockly-mathematik/blockly-mathematik-8-en.svg - Logo

Random numbers

In Blockly you can get random numbers. There are two different blocks available.

/images/2020-04-08-blockly-mathematik/blockly-mathematik-11-en.svg - Logo

With the block ‘integer random value’ you can have an integer random value from a defined value range output.

/images/2020-04-08-blockly-mathematik/blockly-mathematik-12-en.svg - Logo

With the block ‘Random number (0.0-1.0)` you can output a random decimal number between 0.0 and 1.0.

Distribute values

With the ‘Distribute Value’ block you can distribute numbers, e.g. measured values, to a new value range (mapping). This is useful if you want to convert your measured values directly into a percentage between 0 and 100.

/images/2020-04-08-blockly-mathematik/blockly-mathematik-13-en.svg - Logo

At the free block sections, the limits of the original and the limits of the new value range must be defined using the ‘number’ blocks.

In the following example, the entire value range of the brightness sensor (from 3 to 200,000 lux) is distributed over a new value range from 0 to 100.

/images/2020-04-08-blockly-mathematik/blockly-mathematik-14-en.svg - Logo


The latest tutorials sent straight to your inbox.