Custom Extension generated code in incorrect order


Hi, Ia have created an Extension to be used with an arduino car. I can install the extension and it generates code properly but if I mix my blocks with arduino ones the code of the arduino block is always inserted before mine no matter where I put my block.
Add “Arduino Program” from Arduino extension
Add “Init Car” block from my extension
Add Serial.Print(“Car initilized”) from Arduino extension.

And the resulting Arduino code is

void setup(){
Serial.println(“Car Init”);
pinMode(enableRight, OUTPUT); <-- Begin Init Car
pinMode(enableLeft, OUTPUT);
pinMode(rightMotor1, OUTPUT);
pinMode(rightMotor2, OUTPUT);
pinMode(leftMotor1, OUTPUT);
pinMode(leftMotor2, OUTPUT); <— End Init Car

If I add more blocks from different extensions mBlock seems to order my extension code lines together,not in the order I added the blocks



It is helpful to place a picture of blocks.
But your problem is that you incorrectly placed code in your extension, or you don’t use block “Forever”.
Code in section “Setup” not very important the order in which blocks are located.

Use block “Forever”, or replace code from “Setup” to “Work” in your extension.


You are right, I misunderstood the block type use (work, setup) etc. I didn’t use the loop because I was trying to do some simple movements once.

Now I use the loop and the code is ordered but some more info on how to make extensions would be great.

Thanks for your help


The site has good instructions, but you probably already read it ( Further experience and common sense.

I described my experience of creating extensions and gave practical advice on one site, but there all in Russian, in English it is difficult to write large texts for me.

So write on this forum, there are many practitioners who will help.