loading

Many people have worked and also got frustrated because they haven't been able to load arbublock in ECLIPSE.

I give you in every detail the solution , to create block for ardublock WITHOUT ECLIPSE.

It is ,very simple solution .

Step 1:

download Notepad++ https://notepad-plus-plus.org/
From ardublock.jar\com\ardublock\block drag and drop out

block-mapping.properties , ardublock.properties , ardublock.xml

In ardublock.xml describe all blocks buttons connection multi-choice and others.

In ardublock.properties make statement for names.

In block-mapping.properties connect "names" with class files.

Step 2:

First let's make a "button" in ardublock .

Open notepad++ and load ardublock.xml

Write in family BlockDrawerSet :
< BlockDrawer button-color="000 000 000" name="bd.mybutton" />

Save.Info for colour RGB www.rapidtables.com/web/color/RGB_Color.htm.

Open with notepad++ ardublock.properties and write in last line
bd.mybutton=my instructable ,and save.

Drag and drop ardublog.xml and ardublock.properties in ardublock.jar\com\ardublock\block.

Step 3:

Run arduino and ardublock.
Congrats ,you've just made a "button".

tip : in notepad ctrl+f quiqly search.

Step 4:

Let's make one block and connect it to ardublock.

Write code as seen in the picture inside ardublock in field BlockGenues

In the same file(ardublock.xml) in field BlockDrawer we must make statement :

Write code as seen in the picture.

(I wrote here the code but "instructuble" does not accept some symbols and deletes my code. )

Open ardublock.properties and write in last line :

bg.myblock1=command block
bg.myblock2=data block

Save and drag and drop both files in ardublock\com\ardublock\block

Open arduino ardublog

Congrats , you've just made your first 2 basics blocks.

Basically we use 2 two types of blocks "commad" and "data"

tip : -- sam --> is label with ctrl+f (quick find) you can jump from one flag to other.

change code for "data block" as you see in the picture. Result in picture .

connector-type="poly" means that , this block is connect everywhere.

There is few types connection .Search the ardublock.xml and you unterstand what i mean .

Its not nessesery to write code from picture .Best way is to copy and past from other inside ardublock.xml.

Step 5:

PROBLEM:

I want to make a block for MPU6050 chip and get value rotation from chip , axis X accelerometer .

I want one block which produced code as in the picture { without Serial.begin() Serial.Print() and Serial.println() }

(this block does not exists.)

SOLUTION :

Open arduino ardoblock and make sketch with mesurerX (duinoEdu).See the code in arduino .

MPU6050 is like block of duinoEdu mesurerX .

We want the SOURCE CODE of this block (mesurerX).

The location is C:\ ARBUBLOCK\com\ardublock\translator\block\DuinoEDU\Acc_mesurerX.java.

(In my previous post 2/3 I describe with every details ,how make a folder ARDUBLOCK with subfolder com and edu.)

( https://www.instructables.com/id/23-EDIT-AND-CREAT... ).

Open it with java editor .

( My opinion is open and other java files and try to understand what you see from code.)

If you open other java files from ardublock you will see that everything is about the same at the beggining .

In ardublock make sketch with Rfid read ( duinoEdu)

The location of SOURCE CODE is C:\ ARBUBLOCK\com\ardublock\translator\block\DuinoEDU\Rfid_Read.java

Open and this with java editor.

Take a look at the code from both sides .Its nearly the same.

Few words

addHeaderfile ("library.h") - add library on header ( top )

addDefinitionCommand () - possibly other block add library on top .This command after of all "libraries" adds comments or anything else you do in arduino before setup(). Use \n for continouing code

addSetupCommand - In field setup add code

String ret - in fields loop() add code

In my first post ( https://www.instructables.com/id/13-How-to-EDIT-and-CREATE-blocks-in-ardublock-WITH/ )

i describe that the \n means next line .See it in pictures in java files.

Step 6:

Lets write the java file

I work on file Rfid_read.java

Change in line 8 and 9 Rfid_Read with MPU6050_GetAcceleration_X

Add in line 18 translator.addHeaderFile("Wire.h");

Change line 19 translator.addHeaderFile("I2Cdev.h");

Change line 20 translator.addHeaderFile("MPU6050.h");

line 21 translator.addDefinitionCommand("MPU6050 mpu ;"

line 22 translator.addSetupCommand("mpu.initialize() ;");

line 23 String ret = "map(mpu.getAccelerationY(),-17000 ,17000 , 0, 179 )";

That's it .Save it as MPU6050_GetAcceleration_X.java in C:\ARDUBLOCK.

Make java to class.

I describe with every detail in previus post PART 2/3 how to convert java to class .

( https://www.instructables.com/id/23-EDIT-AND-CREATE-BLOCK-IN-ARDUBLOCK-23/ )

Step 7:

Lets make "data" block better.

Open ardublock.xml with notepad++ . Find "myblock2" (with ctrl+f) and delete some code as seen in the picture .

Let's put a photo inside block

Create two folder in ardublock
1.Create in ardublock.jar\com\ardublock\translator\block new folder name " myblocks " (it's for class files )

2.Create in ardublock.jar\com\ardublock\block new folder name " myblocks " (it's for photo files )

Write in google MPU6050 and go to picture copy photo of chips and paste in painter .

The size must t be small ( see the picture ) and save it as 6050.png

Drag and drop photo 6050.png in ardublock.jar\com\ardublock\block\myblocks

(in ardublock change 6050.PNG to 6050.png it's different )

Open ardublock.xml with notepad++ and write as seen in picture (or make copy paste from others).

Save it (last time) .Drag and drop ardublock.xml to ardublock.jar\com\ardublock\block.

Open ardublock.properties and change:

bg.myblock2=data block to bg.myblock2=MPU6050_X. save it and back to ardublock.jar

Open ardublock .See the result .

Step 8:

Add class to ardublock

Drag and drop out from ardublock.jar\com\ardublock\block\block-mapping.properties

In the end write :

myblock2=com.ardublock.translator.block.myblocks.MPU6050_GetAcceleration_X (see picture)

Save and back to ardublock.jar\com\ardublock\block .

Open class editor ce and load MPU6050_GetAcceleration_X.class

In class properties in field class name delete duinoEdu and replace with myblocks ( picture )

also change major version from 51 to 49 .

Accept and Save .

Drag and drop MPU6050_GetAcceleration_X.class to ardublock.jar\com\ardublock\translator\block\myblocks\

save and exit .

Make sketch with new block.

Result ( picture ).

Step 9:

PROBLEM :

I want to have FULL access to values ( see picture )

SOLUTION :

Drag and drop out arublock.xml .Find " myblock2 " and add lines ( see picture ) drop back ardublock.xml and run arduino ardublock (see picture ).

Open arduino ardublock and make scketch with "stepper motor step sped (duinoEDU) ".

Load in class editor MPU6050_GetAcceleration_X.java .

Load from C:\ARDUBLOCK\com\ardublock\translator\block\DuinoEDU\Stepper_SetSpeed.java in java editor.

Look both codes, It'a a very simple code .It;s simply to modify it.

Copy from Stepper_SetSpeed.java and paste in MPU6050_GetAcceleration_X.java ( see picture ).

Total code ( see photo )

Make java to class ( described with every details in part 2/3 https://www.instructables.com/id/23-EDIT-AND-CREATE... )

Load class file to class editor . In filed " Class Name " delete duinoEdu and write myblocks .

In field " Magic number " replace 51 to 49 . Press Accept and Save.

Push it back to folder .

Result ( photo )

E N D

About This Instructable

2,092views

15favorites

License:

More by Samouel Kastoria:3/3 Create block  WITHOUT ECLIPSE for ardublock . 2/3 EDIT AND CREATE BLOCK IN ARDUBLOCK 2/3 1/3 How to EDIT and CREATE blocks in ardublock WITHOUT eclipse 1/3  
Add instructable to: