Notifications
Clear all

Any ArduBlockly Developers here?

9 Posts
3 Users
0 Likes
5,183 Views
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  

I've become interested in block coding and would like to learn how to create custom blocks.

I have a challenge for anyone who is brave enough to take it on. ?  (see below)

I'm trying to learn how to create and install new code blocks that aren't currently available in the ArduBlockly program.

Here's what I've done thus far:

I downloaded and installed ArduBlockly from Github releases HERE

I got version 1.2 for windows.  It appears to be working, although it won't verify or upload code, but that's a problem I can deal with later.  At least it will create the code and I can save it as a *.ino file and open it with the standard Arduino IDE and upload it to the boards from there.  So far that's working.

The other problem with ArduBlockly is that it has limited blocks to work with.  I'm working with an Arduino Mega board and I need to use multiple serial ports.  But as far as I can see the ArduBlockly program only offers one Serial  block with no option to chose the other available serial ports on the Mega.   So one of the first things I need to do is create a new block that will offer this additional functionality.  I'd like to be able to chose from all the available serial ports on the Arduino Mega.  This is only the tip of the iceberg, but it seems like a simple enough place to start.

If we look at a screenshot of ArduBlockly with the serial block in place we can see the  Arduino code that it generates in the right hand window:  There's not much code to it.  It just creates a Serial.begin(9600); statement with the chosen baud rate.

ArduBlockly Arduino Code

We can also look at the XML block code for this block.

ArduBlockly XML Block Code

This is the code that was written to generate this Serial Com Setup block.

I'll paste the code here just for clarity.

<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="serial_setup" id=":yP%jE_oiZx-zeG]{!98" x="2" y="-424">
<field name="SERIAL_ID">Serial</field>
<field name="SPEED">9600</field>
</block>
</xml>

So this gives you some vague idea of the code that generates these code block puzzle pieces.

Next Journey for Code Block Development:

I've done a little bit of research, and tried a few things, but I'm getting in too deep and it's not panning out quickly.

Here's what I've done in the way of research:

I found this page: Define Blocks

And that led me to this page with a nice instructional video: Blockly Development Tools

And this finally led me to the online Block Factory

There I spent a few hours trying to develop a custom block.  But I found that it wasn't as easy as it looks.  Also after I had created a new custom block I have no idea how to install the newly created block into ArduBlockly so it shows up as a usable code block puzzle piece.

The CHALLENGE!

Anyone up to trying to create a second Serial Setup block for Serial1, Serial2, or Serial3 to be used with a Mega Board?   Or maybe one block that has the option of setting the serial number?

I didn't even try to do that yet myself.  I was trying to create a UDP Communication block.   But I thought for this challenge maybe we should try something a bit simpler?

Anyway, my eyes are bloodshot and this is becoming too time-consuming for me.   But I would like to learn how to create my own custom code blocks that can be used with ArduBlockly (or similar type of  code block programmer)

Why am I doing this?

Why not just write the code in C++ on the standard Arduino IDE?  I already did that.  I want to learn how to design new code blocks for ArduBlockly. ? 

I want to transfer a program I already wrote in C++ into block codes on  ArduBlockly.  But I need to design the puzzle pieces to make it work first.   This could be worth learning as this Blockly programming style is a growing tool that a lot of people are starting to use.   Once we do a few code blocks and figure out all the little tricks,  it should be easy to create anything we need.

Anyone game?

If  you take on this challenge, please do share your success. ? 

 

DroneBot Workshop Robotics Engineer
James


   
Quote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

I have to say, I'm not a big fan at all of these plug and play type graphical tools, because I actually love to program and have full control over the outcome of my code, and love to challenge myself to make it better.  I also do not believe in these tools, because I think they restrict people from actually being creative and learning how to really code, where real thinking in design, structure and algorithms come into play.

Having said that, I just downloaded it (Ardublockly) for fun, and found it's development to be at a very amateur level.  However, to answer your question, and this is by no means definitive... I found that when I connect my Mega, it initially shows only the one serial port in the drop down list of the serial block?  But, if I go to Edit->preferences, and change the board type to something else (say Nano) then back to Mega while connected to the board, I actually see the following ports now become available:

From this:

Blocky Serial 1

To this:

Blocky Serial 2

Looking at some of the code behind the blink example, it appears that these ports and baud rates are dynamically retrieved via some system calls, and so I am not sure if what you want can be done via the tools available via the current API predefined block set.


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  
Posted by: @frogandtoad

I have to say, I'm not a big fan at all of these plug and play type graphical tools, because I actually love to program and have full control over the outcome of my code, and love to challenge myself to make it better.  I also do not believe in these tools, because I think they restrict people from actually being creative and learning how to really code, where real thinking in design, structure and algorithms come into play.

I'm not looking to change the way I personally code.   I too prefer using the actual coding languages as there is no question they are more flexible.  However, whether we like it or not these graphical programming methods are going to become quite popular among people who aren't interested in learning the actual coding languages.   So there's an opportunity here to grow with where the future is going.  I'm not a fan of self-driving cars either.  But there's coming whether we like it or not.   So this has nothing to do with what I personally "want".  It's just the way reality is changing.   Although I can say that these block programs are a lot of fun to play with even if coding directly is far more efficient for someone who already knows how to program.

Posted by: @frogandtoad

Having said that, I just downloaded it (Ardublockly) for fun, and found it's development to be at a very amateur level.  However, to answer your question, and this is by no means definitive... I found that when I connect my Mega, it initially shows only the one serial port in the drop down list of the serial block?  But, if I go to Edit->preferences, and change the board type to something else (say Nano) then back to Mega while connected to the board, I actually see the following ports now become available:

Yep, you're right, that did work.    I also found other sources for ArduBlockly that had additional features.

The bottom line for me though isn't  that I want any specific blocks but rather that I want to be able to create my own blocks.   I'm sure there are going to be many blocks that I would like to have and that simply aren't available.   So it would be nice if I could just whip up my own when I need them.

I've actually been working with the Block Factory.  I was able to design a Serial setup block and add the additional  serial ports to it myself, so that was cool.   The only problem is that this only created the graphics of the block, but not the Arduino code that needs to accompany it.  Of course I can easily write the Arduino code, but it's not that simple.   You actually need to program the block to generate this code, and this is much more complicated.   In fact programming Blockly Blocks that create Arduino code is far more complex than just writing Arudino code s straight out.  But I'm working on learning how to do this.

Again, not because I want to program using blocks.  But other people may prefer that method, so it's nice to be able to know how to do this.  Once I learn how to program new blocks I might very easily become interested in creating quite a few of them.   I would create blocks to duplicate programs that I can already program on the Arduino using standard C++ code.   I'd be doing this basically for the sake of other people.  In fact, there may be a nice niche for this.   I've noticed that a lot of people appear to be interested in block programming.

Let's face it, for a raw beginner it can be far less intimidating that trying to learn the actual  programming language.

I remember back when computers first started out.  Programmers back then, (including myself) were naysayers concerning "high level languages".   We used to think that programming in anything other than assembly language was for lazy people who simple didn't want to bother learning how  CPUs actually work.

But look at the programming world today.  Almost nobody uses assembly language anymore.   It's all done with higher level languages.

Block programming could be the "New Age" higher level programming language.   Remember "higher level" basically means "easier for humans to use".   Because you can never do anything in a "higher level" language that you can't do in Assembly Language.  It's just a lot easier.  That's all.

So the easier it is to program, the "higher level" it is.  Therefore block programing is very likely to be the next level of high-level language.   If nothing else you've got to confess that it is indeed easier.  It totally eliminates any possibility of a syntax errors.  So that's one headache that is completely gone .

I can see where it's going to be the wave of the future.  People like EASY.   And block programing is definitely that.

Of course programming the blocks is not easy.   Although I hope it isn't too hard either.  I hope that after I learn how to do it even programming new blocks will become easy. ? 

I just created a new UPD packet communication block, but I haven't figured out how to get it to generate the proper Arduino code yet.   This may take a while to figure out how to do this.

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@robo-pi

However, whether we like it or not these graphical programming methods are going to become quite popular among people who aren't interested in learning the actual coding languages.   So there's an opportunity here to grow with where the future is going.  I'm not a fan of self-driving cars either.  But there's coming whether we like it or not.

Indeed, people who are less inclined to learn a formal language may well take up this type of graphical programming, so I agree with that, but don't talk to me about self driving cars 🙂

I've actually been working with the Block Factory.  I was able to design a Serial setup block and add the additional  serial ports to it myself, so that was cool.   The only problem is that this only created the graphics of the block, but not the Arduino code that needs to accompany it.  Of course I can easily write the Arduino code, but it's not that simple.   You actually need to program the block to generate this code, and this is much more complicated.   In fact programming Blockly Blocks that create Arduino code is far more complex than just writing Arudino code s straight out.  But I'm working on learning how to do this.

Likewise, I spent a good hour looking and playing around with the online tools, and also put together a block with its textual representation, but no code, then comes the hard part and the API documentation is not the best I've ever seen - I opened up one of the sketches "Serial Print" for example, and the comments in there are not very helpful, even if you know Java Script, so yes, it does get quite complicated.

Let's face it, for a raw beginner it can be far less intimidating that trying to learn the actual  programming language.

True, and there may well be a niche for developing the backend code.

We used to think that programming in anything other than assembly language was for lazy people who simple didn't want to bother learning how  CPUs actually work.

I always wanted to learn assembly, but never got around to it, and may yet one day.  C++ is by far my favorite language, and yet I'm never happy with my code, always trying to refactor it to smitherines 🙂

I can see where it's going to be the wave of the future.  People like EASY.   And block programing is definitely that.

Again, I can't argue with that... there will always be a push for higher level languages.  Remember, Bill also posted a video on XOD, and there are others too, so a lot of competition around.  This one has the backing of money behind google however, which could be a bad thing, given they already just about control everyone's daily lives.

I hope that after I learn how to do it even programming new blocks will become easy. ? 

I just created a new UPD packet communication block, but I haven't figured out how to get it to generate the proper Arduino code yet.   This may take a while to figure out how to do this.

As with anything, it will certainly become easier the more you practice using it.  Did you mean "UDP"?  That sounds like an interesting little project. Without knowing all the details, JavaScript (although I would prefer JSON), may be required to code at the lower level, as from what I read, there are some things that you just can't code with JSON.

Good luck with it all.

I may well have another look at it at some point in the future and let you know how it goes 🙂

 


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  
Posted by: @frogandtoad

Bill also posted a video on XOD, and there are others too, so a lot of competition around.

Yes, I've messed with XOD too.  But I'm willing to bet that XOD loses out to Block programming because in the end Block programing is still much easier for beginners.     XOD is too much like wiring up circuits and that will intimate a lot of people.   So I predict that Block programming is more likely to win the graphics programming war in the long haul.   Clicking puzzle pieces together is just too darn easy.   And the program won't even allow you to click wrong pieces together.

Posted by: @frogandtoad

Did you mean "UDP"?

Yep.  Typo.  Me bad.

Posted by: @frogandtoad

Without knowing all the details, JavaScript (although I would prefer JSON), may be required to code at the lower level, as from what I read, there are some things that you just can't code with JSON.

Yes, you can use either, but they recommend  JavaScript probably for the reason  you've mentioned.

Posted by: @frogandtoad

Good luck with it all.

I may well have another look at it at some point in the future and let you know how it goes

If I ever learn how to do it myself I'll post what I've learned.   I've already found some tools that will generate Python, PHP, Dart and some other languages for you.   But I haven't found an Arduino Code generator yet.   So that's where I'm at right now.

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@robo-pi

I got version 1.2 for windows.  It appears to be working, although it won't verify or upload code, but that's a problem I can deal with later. 

Oh, I forgot to mention that I did get mine to launch the IDE, so if you or anyone else hasn't yet, it was all done under the Edit -> Preferences menu:

I set the compiler location as follows:

Arduino Blocky Path 1
Arduino Blocky Path 2

I then chose the following of the three options in the drop down list:

Arduino Blocky OpenInIDE 1

Clicking the Open Sketch in IDE icon then launches the IDE as follows:

Arduino Blocky OpenInIDE 2

Cheers.


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  
Posted by: @frogandtoad

Clicking the Open Sketch in IDE icon then launches the IDE as follows:

Ok,  that's the part I was missing.  I had it set to just the verify button.   It ends up doing basically the same thing I was doing.  It just opens the IDE with the code.  I was copying and pasting the code into the IDE.

But thanks, now I can just click on  the Open IDE  button and it automatically copies the code into the IDE for me.

By the way I'm making progress  on learning how to create new blocks.    I've learned  how to use the Block Factory to create the jigsaw blocks.  Now I'm working on learning how to  fill in the Arduino code.  It's not as straight-forward as just typing in the code as you would normally do it in the  Arduino  IDE.  Instead you need to build the code up using Java statements and concatenating together each in individual Arduino code keyword and variable.

But I'm getting there!

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
(@joeldee)
Member
Joined: 4 years ago
Posts: 5
 

Sorry for interrupting. I am new and trying to learn how to ask a new topic question?

I see nothing that relates to a new topic?

Thank you for your patience--joel


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  
Posted by: @joeldee

Sorry for interrupting. I am new and trying to learn how to ask a new topic question?

I see nothing that relates to a new topic?

Thank you for your patience--joel

Hi Joel,

The first thing  you need to do is decide which forum is best suited to the question you want to ask.

You can do this by clicking on the Forums tab:

Forums

Then look over the list of forums and sub-forums until  you find one that suits  your topic

For example if  you want to ask a question about power supplies might choose:

Components and Programming

And then choose the sub-forum:

Power  Supply & Batteries

And then chose the ADD TOPIC button to the right of that category heading

This will start a new thread for your question in that topic.

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote