Security
Secure data upload to openSenseMap
Informations for the visual programming environment Blockly for senseBox.
Decisions or branching in programmes are among the most important control structures in programming. They allow you to adapt your program to different conditions.
The if, do
block has two free block sections ‘if’ and ‘do’.
The actions linked to the free block section ‘do’ are only executed if the condition linked to the block section ‘if’ is fulfilled.
For example, the built-in LED on the senseBox MCU should be switched on when the built-in button is pressed.
Commands added after the ‘if, do’ block will be executed in any case, even if the condition was not fulfilled before.
With a click on the small cogwheel in the top left corner of the if, do
block you can add a ‘else’ block section to the block. Commands stored in this block section will only be executed if the condition wasn’t fulfilled before. If the condition was filfilled, they are skipped.
For example, here the built-in LED 1 should only light up when the built-in button is pressed else the built-in LED 2 should be switched on.
With a click on the small cogwheel in the top left corner of the if, do
block, you can add a ‘else if’ block section to the block. Now first the top ‘if’ condition is checked, if it is not fulfilled the following ‘else if’ condition is checked. This way only those commands are executed whose associated condition is true.
For example, depending on the temperature an LED should be switched on. At temperatures below 0°C LED 1 should be switched on, at exactly 0°C LED 2 and at temperatures above 0°C LED 3.
In Blockly you have the possibility to use different logical operators to compare measured values. With the help of these operators you can also formulate more complex logical expressions by logical operations.
With the block for logical comparisons
values can be compared.
With the block for ‘logical operations’ more complex logical Asudrucks can be formulated. For example, a lamp that only lights up when two conditions apply.
The block offers a choice between the operators ‘and’ and ‘or’.
and
links two conditions together, so that both must be met for the entire expression to be evaluated as true.
Or
combines two conditions so that only one of them must be true for the entire expression to be true.
With the ‘not’ block, expressions can be negated. A condition is true if the input value is false and false if it is true.
With the ‘test’ block, a condition can be checked and actions can be defined which are executed depending on the result.