fbpx
Magicblocks Lesson 02: Introduction to Magicblocks playground
Magicblocks Lesson 2

Introduction to Magicblocks playground

Magicbit Blocks

https://github.com/magicbitlk/Magicbit-Magicblocks.io/blob/master/Images/digitalIn.PNG?raw=true
Sample code build

Following Blocks are available.

  • Digital Out
  • Digital In
  • Analog Out/PWM
  • Analog In
  • Serial Tx
  • Serial Rx
  • Servo
  • Display
  • Buzzer
  • Motor
  • DHT11
  • NeoPixel
  • Ultrasonic

This block set enables you to control individual pins of the device from the playground. The functionality of each block is described below:

How to Configure Blocks

Every block has a property called Device ID, where you need to specify to which device this block belongs. This is important because you will be working with multiple devices in a typical IoT project. You can find the device ID from the Magicblocks device manager.

Digital Out

Digital Out, sample code build
Digital Out, sample code build

This block is used to set a digital output pin to 1 or 0 based on the input. An input of 1 or true will make the configured pin go HIGH, and vice versa.

  • Configuration
    • Pin: pin number of the Digital pin to write to. Available pins can be selected from the dropdown list.
    • Name: Any name desired
  • Input
    • value to be written to the pin. Accepts 1 (true) or 0 (false) eg: {“payload”: 1}
Digital In

Digital in Sample code build
Digital in Sample code build

This block will read the Input status of a pin. There are two methods to get input 1. Poll — Block needs to trigger to get input status. Any input will serve as a trigger. (EG: inject block) 2. Interrupt — If there is any change of pin state of Magicbit block will output the current state, Input status can be passed to another block or viewed on the debug window.

  • Configuration:
    • Pin: pin number of the digital pin to read. Select from the drop-down list.
    • Name: Any name desired
    • Method: Poll/Interrupt
  • Input
    • Any input. Used as a trigger.
      • Output
      • Value of the pin as 1 or 0 in the following format and the pin number as the topic
Analog Out

Node connection, Analog Out.
Analog Out, sample code build.

This block is used to set PWM to pins of Magicbit. The value should be in the range of 0-255. An inject block or output of another block can be used to set the value.

  • Configuration:
    • Pin: pin number of the to set PWM. Select from the drop-down list.
    • Name: Any name desired
  • Input
    • Inject block or any block. The input value should be in the range of 0-255
Analog In

Analog In, sample code build.
Analog In, sample code build.

This block will read the analog value of the ADC pin of the module. Similar to the digital in the block, you need to set the method to read the value. Any input sent to the block will serve as the trigger. 1. Poll — Block needs to trigger to get input status. Any input will serve as a trigger. (EG: inject block) 2. Interrupt — If there is any change greater or less than the threshold value of, the Magicbit block will output the analog value.

  • Configuration:
    • Pin: pin number of the analog pin to read (Required)
    • Name: Any name desired
    • Method: Poll/Interrupt
    • Threshold: If interrupt method selected value, return from the output if there is any change greater or less than this value
  • Input
    • Any input. Used as a trigger.
  • Output
    • Value of the pin from 0 to 4096 (12bit ADC) {“payload”: 965}

Playground

The editor window consists of four components:

  • The header at the top, containing the deployment button, main menu, and, if user authentication is enabled, the user menu.
  • The palette on the left, containing the nodes available to use.
  • The main workspace is in the middle, where flows are created.
  • The sidebar is on the right.

Interface breakdown; On top — Header, On right — Palette, On middle — Workspace, One left — Sidebar.
Interface breakdown

The main workspace is where flows are developed by dragging nodes from the palette and wiring them together. The workspace has a row of tabs along the top; one for each flow and any sub-flows that have been opened.

Flow

Tab name is shown as flow
Flow tab

Adding a flow

To add a new flow, click the image:: https://github.com/magicbitlk/Magicbit-Magicblocks.io/blob/master/Images/plus.png?raw=true

button in the top bar.

Editing flow properties

To edit a flow’s properties, double-click on its tab in the top bar. This will open the Flow Properties dialog.

Within the dialog, the flow’s name and description can be set. The description can use Markdown syntax for formatting and will appear in the Information sidebar.

The Status property can be used to disable or enable the flow.

The menu which allows to edit settings.
editor-edit-flow

Deleting a flow

To delete a flow, click the ‘Delete’ button in the Flow Properties dialog.

Related Posts
Leave a Reply

Your email address will not be published.Required fields are marked *