Intro

To make it faster and easier for our third-party developers to develop extensions, we have simplified parts of the development process by providing a preset template called "Default Arduino template" for the most common Arduino extensions. Arduino extensions allow developers to focus only on the options that are configured and useful for the Arduino extensions in the development process, without being distracted by the other settings of the extension builder that are for developing various kinds of extensions.

In short, if you want to develop extensions for the Arduino, choose this template.

Steps

Select template

After entering the extension builder, select "My Extension" and Click "Add extension":

图片

Note: the "Universal template" refers to the original way of developing extensions (if you've ever used before), which allows the creation of more kinds of extensions. For details. please refer to Universal Template

Enter the extension name

Select the "Default Arduino Template" and enter the name of your extension:

图片

Complete the name input, click OK

Extension blocks configuration -- Primary configuration

After above steps, you will be lead to the configuration page, where we've automatically generated the first block category and the first block within it, and you can go ahead and configure the content of the block:

图片

At the bottom of the block configuration page, you can do other block-specific configuration operations, such as modify block runtime code and check on / off black-relevant options:

图片

  • [ When block is running(onRun) ] is usually used for code configuration in the Arduino online mode;
  • The block options,
    • [ Enlarge gap between two blocks ] : add the space between the building block and the adjacent building block in the IDE's block panel, for better block classification;
    • [ Default transcoding for scripts in combination with this block ] : refers to the block generally used as an "event" type building blocks, only blocks under this type of block will be transcoded;
    • [ This block comes with a checkbox for reading value. ] : refers to the building block generally has a return value, which can also be displayed in real-time on the stage. It is only valid for the number and string blocks;

If your extension is simple, chances are you've almost completed your first Arduino extension. Save the blocks and click the "Preview" at the top right to preview your extension!

CONFIGURE building blocks -- Other configuration

Advanced Configuration

If you want to further configure the extension, you can do so in the "Advanced Configuration":

图片

For more details about the configuration of the various parameters in advanced configuration, please refer to this section of tutorials:

Translation settings

You can also internationalize the extension in translation settings:

图片

Example -- Arduino LED lights

In this tutorial, we will use the "Arduino Default Template" to make an extension to control Arduino's LED light. We will use the LED module from Seeed's Grove Kit as an Example, But you can simply apply this to other electronic kits.

Compare with Univeral Template

We have another tutorial showing you how to make the same LED extension but with the Universal Template. If you are wondering the advantages of using "Default Arduino Template" over the "Universal Template" for developing Arduino extensions, you can read the Add LED Light Extension to Arduino Uno, and get the answer from how the two templates differ in each step.

1. Enter the extension name

We enter the extension name first and then go to the extension configuration page

2. Extended configuration

We can then proceed to configure the first block of the first block category:

图片

Type in block text

For example, I wish to create a block like LED Light (port name) (on/off)

In the "Content" region, I enter "LED Light ", then an "@" symbol. As soon as I enter the "@" symbol, a popup appears, allowing me to choose the type of the field I wish to add to my block.

图片

Configure drop-down box parameters

Since my field is a drop-down of Arduino Ports, I chose "Dropdown". Then a dropdown appears. In this way, I can add all my fields and preview my block on the block editor.

Then I select the first tab to create options for the first dropdown. Enter "port" as the parameter name, then click the "Plus Sign" at the bottom of the tab to enter the option input screen.

Note: Click "+" to set the parameters in batches.

图片

Seeed allows me to plug LED Lights into the digital ports, naming D1 to D8. So I input the name of the ports and their respected values for the Arduino Code, 1-8. The "name" and the "value" is separated by a comma, and each option takes a separate line.

图片

After that, make sure to delete the empty first line by clicking the "X" button:

图片

Configure the second drop-down box: LED state.

In the same method, I added options for the on/off "status" field.

图片

3. Transcoding configuration

Switch to "Upload Transcode" and perform the following code configurations:

  • Declare: This code appears before setup () and is used to declare variables
  • SETUP: This code embeds the setup () function in the Arduino ONCE
  • Code: This code appears where the block is used
  • LOOP: This code embeds the loop () function in the Arduino ONCE

    You can double click the regions below to edit the code of each part.

图片

Check out the documentation for the Grove Suite, and it provides the following sample code for the Arduino:

void setup() {
  // initialize digital pin2  as an output.
  pinMode(2, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(2, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(2, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

According to the above code, we need to do the following: After reading the code, I know that I need to insert pinMode at the setup part and digitalWrite at the code part. This is my transcode settings for my block. I use /{port}/ to refer to the value of the dropdown field named "port".

图片

Then, Click Save

Now, you can click on the "Preview" in the upper right corner of the page to test the blocks (extension) you just developed!

results matching ""

    No results matching ""