Introduction: Control a Motor With Magicbit [Magicblocks]

This tutorial will teach you to control a motor with a Magicbit using Magicblocks.

Supplies

  • Magicbit - Pro

Step 1: Story

Hello and Welcome, This short tutorial will teach you to Control a motor by a Magicbit using Magicblocks.

There are 3 main methods of achieving this goal;

  • By using Inject Block.
  • By using Dashboard Switch.
  • By using Dashboard Slider.

First of all log into to your Magicblocks account,

Magicblocks is an easy visual programming software for program your magicbit. Anyone can program their micro controller by using magicblocks.io and there is no need of programming knowledge. You can sign up for free.

Start and Open the Playground.

Next make sure your Magicbit is connected to the internet and plugged-in and also linked to your account through Device Manager.

All Done? then scroll down to Method 1

List of Items Required

Magicbit: Magicbit is an integrated development platform based on ESP32 for learning, prototyping, coding, electronics, robotics, IoT and solution designing.

Step 2: (Method 1) Setting Up the Inject Block [Method 1]

1. Drag & drop the Inject block from the input nodes section on the left of the screen to the Flow.

2. Double-click on the block and select the type of payload from the drop-down menu to a numerical input (number).

3. Next type a value between 0 & 100 (1 means off and 100 means full speed).

4. Setup an 'Off' node usind the same above method.

Step 3: Setting Up the Motor Block [Method 1]

1. Drag & drop the Motor block from the Magicbit nodes section on the left of the screen to the flow.

2. Double-click on the motor block and type or paste your unique Device id from the Device Manager Tab on your Magicblocks account. [ This will link the motor block with the motor connected to the your Magicbit ]

3. Magicbit has two motor PINs. Connect it to one of them and make sure to choose the correct motor PIN from the drop-down menu.

[Optional] Import Already Setup Nodes

If you had trouble setting up nodes, you can use the import feature in Magicblocks to get the nodes which has been already setup.

  • First copy this code to your clipboard
  • Click on the options menu on the top right-hand corner of the screen.
  • Next hover your cursor over the Import sub-menu.
  • Then click on Clipboard and paste the code on your clipboard to the text field
  • Select current flow or new flow and click on Import.

IMPORTANT

Make sure you type your device id on the motor node properties and choose the PIN which your motor is connected.

Step 4: Finally Deploying the Blocks [Method 1]

1. Connect the inject block with the display node.

2. Click on Deploy button on the top right-hand corner of the screen.

3. After deploying click on the box left-side of the inject block to activate it and this will turn on the motor.

Troubleshooting [Method 1]

  • Check whether your Magicbit is connected to the internet.
  • Check whether the motor is connected correctly and correct motor PIN is used.

Step 5: (Method 2) Setting Up the Switch Block [Method 2]

1. Drag & drop the Switch block from the dashboard nodes section to the Flow.

2. Double-click on the switch node and set up a basic dashboard ui [user- interface] from the drop-down menu and a name for your field.

3. Select the Mode as number input from the drop-down menu for both On and Off. And set on payload as 75 and off payload as 1.

Step 6: Setting Up the Motor Block [Method 2]

1. Drag & drop the Motor block from the Magicbit nodes section on the left of the screen to the flow.

2. Double-click on the Motor block and type or paste your unique Device id from the Device Manager Tab on your Magicblocks account. [ This will link the motor block with motor connected to your Magicbit display ]

[Optional] Import Already Setup Nodes

  • First copy this code to your clipboard.
  • Click on the options menu on the top right-hand corner of the screen.
  • Next hover your cursor over the Import sub-menu.
  • Then click on Clipboard and paste the code on your clipboard to the text field.
  • Select current flow or new flow and click on Import.

IMPORTANT

Make sure you type your device id on the motor node properties and choose the PIN which your motor is connected.

Step 7: Finally Deploying the Blocks & Using the Dashboard UI to Access It [Method 2]

  • Connect the text input block with the display node.
  • Click on Deploy button on the top right-hand corner of the screen.
  • After deploying go to the dashboard ui by clicking the link to dashboard URL on the top right-hand corner of the screen.
  • Toggle the switch on and off to control the motor.
  • Copy the your Dashboard URL and this can be accessed via the internet to display text onto your Magicbit Display from anywhere in the World.

Troubleshooting[Method 2]

  • Check whether your Magicbit is connected to the internet.
  • Check whether the motor is connected correctly and correct motor PIN is used.

Step 8: (Method 3) Setting Up the Slider Block [Method 3]

1. Drag & drop the Slider block from the dashboard nodes section to the Flow.

2. Double-click on the slider node and set up a basic dashboard ui [user- interface] from the drop-down menu and a name for your field.

3. Setup the slider node as below.

Step 9: Setting Up the Motor Block [Method 3]

1. Drag & drop the Motor block from the Magicbit nodes section on the left of the screen to the flow.

2. Double-click on the Motor block and type or paste your unique Device id from the Device Manager Tab on your Magicblocks account. [ This will link the motor block with motor connected to your Magicbit display ]

[Optional] Import Already Setup Nodes

  • First copy this code to your clipboard.
  • Click on the options menu on the top right-hand corner of the screen.
  • Next hover your cursor over the Import sub-menu.
  • Then click on Clipboard and paste the code on your clipboard to the text field.
  • Select current flow or new flow and click on Import.

IMPORTANT

Make sure you type your device id on the motor node properties and choose the PIN which your motor is connected.

Step 10: Finally Deploying the Blocks & Using the Dashboard UI to Access It [Method 2]

  • Connect the text input block with the display node.
  • Click on Deploy button on the top right-hand corner of the screen.
  • After deploying go to the dashboard ui by clicking the link to dashboard URL on the top right-hand corner of the screen.
  • Grab the slider to control the motor.

Troubleshooting [Method 3]

  • Check whether your Magicbit is connected to the internet.
  • Check whether the motor is connected correctly and correct motor PIN is used.