Block programming in App Lab

Hi Arduiners!

I wanted to explore the possibility of adding block-style programming to App Lab.

My aim is to understand whether allowing to write Python scripts and C++ sketches using blocks can be useful for beginners to learn how to get the most out of their Q (and maybe the upcoming Ventuno Q).

I know that many of such IDEs already exist (mBlock, CodeKit, ArduBlock etc.) but none of them currently support the dual-brain programming model of the Q - and I also wanted to give users the possibility to author and distribute their own blocks to the community.

Long story short:

How the proposed patch to App Lab works:

  • A new "Blocks" button allows to switch the workspace to the blocks view (based on Blockly  |  Google for Developers ) - both for .py and .ino files
  • Code gets automatically generated - allowing to scaffold a program. I’ve implemented more than 70 built-in blocks, but I need help in testing & validating the generated code, simulating different use case scenarios
  • Blocks are then serialized and stored in a sidecar (.blocks) file, that sits alongside its companion sketch or script in the Q’s filesystem. Removing/renaming the sidecar gives you back the possibility of manually editing the generated code
  • External block catalogs (e.g. from a local folder - in future fetched from a git repo) can be added to the toolbox, allowing to implement custom blocks. The catalog itself is made of declarative YAML files, that App Lab reads at startup and uses to dynamically make blocks available in the toolbox
  • Each block definition YAML file in the catalog describes 1+ blocks: shape, behavior, connections, inputs & outputs, parameters, template code to be generated etc.
  • (automatic update of app.yaml, sketch.yaml and brick config files is not supported, for now...)

Happy to hear your thoughts!

  • Would it be a good idea to add block programming to App Lab?
  • Do you think that people will be interested in contributing blocks, "packaging" their programming experience on the Q into reusable blocks?
  • Would block programming allow beginners to exploit the capabilities of the dual-brain nature of the Q, tackling more complex problems requiring bricks (e.g. encapsulating a brick's functionalities into blocks)?

To test it: clone the repo, follow the standard README to setup a development environment and launch App Lab like this:

BLOCK_CATALOG_PATH=<my-local-blocks-catalog-path> yarn start-app-lab-desktop

Note: BLOCK_CATALOG_PATH is entirely optional - App Lab already ships with many built-in blocks.

Thanks a lot for your help and support!

Welcome to the forum

Personally think that beginners using an Arduino Q is not sensible whatever the programming environment.

They will either do relatively simply things that could be done more cheaply on a Uno R3 or jump into something so complicated that they soon get lost.

Thanks a lot!

Well… I’m wondering whether block programming would actually help those beginners not to get lost too soon :sweat_smile:

You are obviously going to get varying opinions on this but it seems to me that the basic needs of a beginner are well served by the current block languages using say a Uno R3.

What functionality of the Uno Q that goes beyond the R3 do you envisage being programmed in a block language ?

I am a beginner in App Lab. What is a block programming. Give example in tutorial forn so that I can follow it and run it to see a visible result like blinking the onbord LED3_R.

I think block programming of a more breadboard compatible arduino would be worthwhile.
Some of those boards are cheaper than R3...
Maybe this is already available...

There are a number of Arduino block programming apps. Try a search for "arduino block programming software"

I'm thinking that packaging the most common use cases where bricks are used (e.g. classification tasks and detection tasks) into blocks, could be useful for those ones that want to experiment with ML/AI and find it difficult to abstract concepts from Python code.

Something like this:

Give an example that can be run on UNO Q using App Lab. The same request I made to you in post #5.

Hi! Block programming means assemblying software using a visual interface that allows to drag&drop "blocks" representing pieces of code (C++/Python), instead of writing them.

Currently App Lab does not allow to do that (there are no examples or tutorials); that's why I started to implement a version of App Lab that adds this functionality.

The screenshot(s) I posted show how my customized version of App Lab looks like, as of now. Maybe something similar will be implemented by the Arduino Team in the future, shall the community find it useful.

In case you might be interested in a project that took a different approach to block-based programming in Arduino Apps, you can take a look at this: