Advanced Arduino Extension v3.1 for mBlock
Author: Aleksandr Grigorev
What is "AdvancedArduino" (Русское описание расширения Advanced Arduino Extension v1.0 for mBlock)
"AdvancedArduino" is an extension for the mBlock visual programming environment , which can be used instead of basic "Arduino" extension, and has a lot of extra options when working in Arduino mode.
- new blocks for a number of the most popular library functions of Arduino IDE (min(), max(), constrain(), map(), pow()), intended for converting values;
- additional blocks for working with serial communications (Serial, and also Serial2);
- most basic blocks named with classic library function names (like "digitalRead");
- "def" and "code" blocks allows inclusion of custom code snippets written in "Wire" (Arduino IDE) programming language;
- ability to use any library functions of Arduino IDE in the code snippets;
- option to define custom functions that return values of arbitrary type;
- ability to use global and local variables and function parameters of arbitrary type, including arrays.
Attention! The mBlock visual programming environment generates the Arduino code sketch using the "double" type for all variables and function parameters created in the visual mode. Do not forget, if necessary, cast the value to another type - int (), byte (), String ().
Installing the AdvancedArduino Extension
First method
- Run mBlock and select Extensions -> Manage Extensions from the menu. The extension list will be downloaded from MakeBlock website.
- Type "AdvancedArduino" in the "Search" field. You will see the "AdvancedArduino" element on the list.
- Click on the "Download" button of the "AdvancedArduino" element.
Second method
- Download or copy "AdvancedArduino.zip" file to your computer.
- Run mBlock and select Extensions -> Manage Extensions from the menu, then click on the "Add Extension" button.
- Select the file type "zip-file", scroll to the downloaded archive, then click on the "Open" button.
If you have any questions, look at the additional instructions from the Makeblock developers:
http://www.mblock.cc/docs/create-extensions-for-mblock/
Examples of using the AdvancedArduino extension
Sample 1 ( file)
Blocks with custom code snippets (Arduino IDE code, "Wire" programming language) in a graphical script.
Attention! When mBlock generates Arduino code sketch, it comments out the code () and def () block values using the /* and */ directives. To make the code fragment visible to the compiler, it is necessary to put the CLOSE "bracket" ( */ ) in the BEGINNING, and the OPEN “bracket” ( /* ) at the END.
Sample 2 ( file)
Рort number in the function parameter.
Sample 3 ( file)
"Counter" block and "repeat" loop (use Serial monitor).
Sample 4 ( file)
Рort number in the function parameter and "counter" block.
Sample 5 ( file)
Transmitting of messages from Serial2 to Serial, an explicit conversion of the value to char type.
Use with ME Auriga or Arduino Mega 2560, use "Auriga Program" header or "Advanced Arduino Program" header.
Sample 6 ( file)
Blocks with library Arduino functions (value conversion functions).
Sample 7 ( file)
Variables of any digital type (demo of overflow with byte variable).
Sample 8 ( file)
Variables of any digital type (how to calculate factorial).
Sample 9 ( file)
Using arrays.
Sample 10 ( file)
Define custom functions that return values.
Sample 11 ( file)
The "line" addition of the custom code snippets.
Sample 12 ( file)
Using the text file saved on the disk.
The disk must contain a text file with the appropriate name and content. If it is necessary, change the path to this file in your script.
Contents of the text file:
Sample 13 ( file)
2D arrays (multiplication table).
Sample 14 ( file)
String variables.
Sample 15 ( file)
"Length" method with String objects. Names matching (visual blocks and text code).
Sample 16 ( file)
Morse transmitter based on mCore controller.
"morse-ext-Dat.txt" file
Sample 17 ( file)
Array of functions
Sample 18 ( file)
Running shadow processes (use the name "myUpdateFunction" for your custom block).
Sample 19 ( file)
Several shadow processes. Use mBot educational kit with Servo Pack and 3-axis Gyro module
Sample 20 ( file)
Shadow processes. "Static" local variables.
Sample 21 ( file)
Shadow processes. "Static" local variables with similar names.
Sample 22 ( file)
External interrupts. Use names "myHandlerFunction0", "myHandlerFunction1", etc. for your custom blocks. Use "volatile" variables.
Sample 23 ( file)
Compound operators. Increment, decrement, side-effects.
Sample 24 ( file)
Scheduled processes. Use names "myScheduledFunction1", "myScheduledFunction2", etc. for your custom blocks.