Saving code as a MyBlock

The chunk of code we made is the first of the four intelligent MyBlocks that make the Falcon's programming smart. Now that we have the code written out, follow these steps to save it as a MyBlock:

  1. Click and drag your cursor to select all of the code that you wish to include in the MyBlock. The code that is successfully selected will be highlighted in blue. Do not include the Start block in your selection.
  2. In the top-right corner of the screen, navigate to ToolsMy Block Builder.
  3. Using the My Block Builder wizard, set up your new MyBlock by naming it and selecting an icon. There are many icons to choose from, so choose an icon that represents what your new MyBlock does.
  4. When you are satisfied, click Finish in the bottom-right corner of the wizard:

The MyBlock that we are making now should be called steerCenter. The MyBlock wizard also allows you to set up parameters; these are input and output values for your MyBlock. Since none of the MyBlocks we will make for the Falcon use parameters, you can ignore this for now, but it may prove to be useful in your later projects. We will extensively use the parameter feature in the next chapter.

After you click Finish, your code looks like this:

Congratulations! You have successfully saved your first MyBlock. The EV3 will execute all of the code contained within this MyBlock wherever you have placed it in the program. The MyBlock acts as a placeholder for all of the code we just wrote. If you need to edit a MyBlock, double click on it and it will expand to show all of the code contained inside.

All of the MyBlocks that you save will be stored under the teal programming tab at the bottom of the screen. You may now drag out your new MyBlock to use it anywhere in your program:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.125.219