MicroBlocks and App Inventor

Would you consider using another programming language then MakeCode? I use MicroBlocks for all my microcontroller programming. Even the App Inventor team had a demonstration together with John Maloney, lead developer of MicroBlocks, during the latest AI summit.

To be clear, I am part of the MicroBlocks team so I am biased. :wink:

You could use MicroBlocks to program the micro:bit in this case. The micro:bit v2 gets a 3 letter code after you installed the microbit vm on it. In the sample aia I attached, you just have to enter the 3-letter code and you can connect to the micro:bit if it is programmed with microblocks. No need to search through a list.

MicroBlocksRemoteControl_Peter.aia (206.3 KB)

As you can see in the aia, you can just send text commands over BLE. On the MicroBlocks side it would look like this when a command is received.

image

I guess it is a lot of info, but App Inventor <-> MicroBlocks is an ideal combination if you spend the time to get to know it.

We still are in need for an extension developer who is willing to make a special Open Source MicroBlocks BLE extension that can be used in App Inventor. It would be much easier to use, because a lot of things, that end users don't need to know are hidden, like all the UUID. The procedures would be blocks in the extension. For all the technical details, you would have to talk to John Maloney.

Okay, thanks for the support. I just downloaded the microblocks and I am in a way lost how do I add microbit. Do you have tutorial that can help. We can chat on whatsApp Removed by mod. Or arrange a call on Zoom or Meet. Thanks

I have been able to use the microblock and also looked at the aia file sent. But the whole thing looks a bit confusing. I think if we can see the microblock code for the aia code it will be easier for us to create what suit our project. Thanks.

I shouldn't have hijacked this topic with my info. It would have been better to to make this a separate topic.

1 Like

Hello Peter, can you please send the microblocks code for the aia you sent. Thanks

There is no specific MicroBlocks code. The aia is a general use project. You type in the commands that you send to the micro:bit or you use the standard available ones.

So for instance you send stop to the micro:bit then you have to use the when received block to make the actions that has to happen.

That is why I gave you the small sample. Just use the aia, send stop and when stop received show the smiley face. Then you know it works.

You should not forget to put the vm on the micro:bit or did you do that already?

I made a new topic with the relevant posts to keep the topics seperated.

Okay, thanks. Yes we used the buttons . So I think I get it now will try it tomorrow and let you know the outcome

1 Like

Where do I see the three letter code? I loaded the VM (I think).

When you power up your micro:bit you see the 3 letter code on your led display of the microcontroller that has BLE. You can also see it when using the BLE id block. Every code is "unique".

image

Ah! I see.

My microbit says it's name is FPE, but when I try to connect using your aia, the Companion immediately disconnects. I tried twice.

I think you should build and install the apk. That is what I did.

My app is also crashing. That didn't happen before the update of App Inventor.

My previous APK still works.

Yeah, my app crashes as apk too. What now?

This is my previous version

The code.appinventor builder is not updated yet, so you could use that. This is something the App Inventor developers have to fix.

Can't you connect using the normal way, displaying a list of BLE devices nearby and then choosing one?

It seems to connect now, I can press the send buttons, but how do I know what the micro:bit sees upon pressing one of these buttons?
And what about the i/o pins that must be adressed in the original question?

Yes you could use a list of ble devices but for many cases this is much easier. Just a 3 letter code. That is the way the aia was made.

You have to program the micro:bit using the when received block, like in the small example I showed. What to do when a certain word arrives.

I tried to find the original question about the pins but can not find it. :slightly_smiling_face: