Your first sketch
First steps
Blockly is the graphical programming interface for the senseBox developed by the senseBox team. It's based on the Blockly Framework from Google and it's available online for free and without any software installation.
Open Blockly for senseBox in your browser by visiting https://blockly.sensebox.de. The first thing you will see is a selection of senseBox versions. Choose the version you are using.
Interface
Once you have selected your senseBox version, you will see the Blockly interface, which can be divided into six sections.
- Menu bar: From the menu bar, you can change the board you are using or the language. On the left side, you can also navigate to the tutorials and the gallery. The tutorials offer a guide for your first Blockly sketches and introduce you to the various sensors and functions of the senseBox. In the gallery you will find selected sketches from the senseBox team.
- The toolbar: Here you will find all the blocks for programming the senseBox. The color of the blocks indicates the category to which the block belongs.
- The workspace: This is where you put your programs together. At the bottom right are buttons to center, zoom in, zoom out, and delete blocks.
- Copy, compile, and other Blockly functions: Here you will find the most important button for Blockly. With the orange 'Compile' button, you can compile and download your created sketch. Additionally, you can rename, download, share, create screenshots of your sketch, or copy the Arduino source code of your sketch to the clipboard.
- Arduino source code and XML blocks: Here you can see the Arduino source code parallel to the graphical programming. By clicking on the XML blocks button, you can switch the view to the XML code.
- Help box: Here you will find a brief guide on how to use the selected block and where you can find more information.
Programming
To write your program, the blocks from the toolbar must be placed in the workspace using drag & drop.
Step 1: Setup and Endlosschleife
This block is loaded directly when the interface starts and should always be used.
The two basic functions Setup()
and Endlosschleife()
are always needed to write a functional program.
Blocks that are inside the Setup()
function are executed only once at the beginning of the program.
Here, for example, the display is initialized or the WLAN connection is established.
Blocks that are inside the Endlosschleife()
function are executed continuously.
The microcontroller always executes all blocks from top to bottom.
In the Endlosschleife()
function, for example, the sensors are read or the measured values are saved on an SD card or transmitted to the Internet.
Step 2: Turn on the built-in LED
To turn on the built-in LED you first have to drag the LED on digital
block into the Endlosschleife()
function.
Then select BUILTIN_1
under PIN and On
under Status.
Step 3: Let the built-in LED blink
To make the built-in LED blink it is necessary to turn it off with another LED on digital block at digital Block.
Additionally, after turning it on and off a pause has to be inserted to make the blinking visible.
You can find the Wait
block in the Time
category.
Compile and download
After your program is finished, click the orange "Compile" button and a .BIN file will be offered for download. Save this file at any location on your computer.