fbpx
Magicblocks Lesson 05: Control light over the internet
Magicblocks Project

Turn On LED through Internet [MagicBlocks]

Control LED on your Magicbit using Magicblocks

Components Required

Story

Hello and Welcome, This short tutorial will teach you to control LED on your Magicbit using Magicblocks.

There are 2 main methods of achieving this goal;

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

First, log into your Magicblocks account,

Magicblocks is easy visual programming software for the program of your Magicbit. Anyone can program their microcontroller by using magicblocks.io and there is no need for 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

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).

Turn On LED through Internet Pic 2
Magicblocks.io Edit inject node.

3. Set up the node name[optional] and number to inject (0 or 1).

Turn On LED through Internet Pic 3
Magicblocks.io Edit inject node.
Turn On LED through Internet Pic 4
Magicblocks.io Edit inject node.

Setting Up the Digital Out Block [Method 1]

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

Turn On LED through Internet Pic 5
Magicblocks.io playground interface.

2. Double-click on the digital out block and type or paste your unique Device ID from the Device Manager Tab on your Magicblocks account. [This will link the digital out block with your Magicbit]

Turn On LED through Internet Pic 6
Magicblocks.io Edit Digital Out node menu.
Turn On LED through Internet Pic 7
Magicblocks.io — Manage Devices.

3. Set the PIN to one of the LED Pins.

Turn On LED through Internet Pic 8
Magicblocks.io playground interface — Edit node 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 that have been already set up.

  • First copy this code to your clipboard;
[{"id":"b08b873f.cdf938","type":"inject","z":"d2db2033.c2624","name":"","topic":"Off","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":300,"wires":[["7c612530.efad4c"]]},{"id":"7c612530.efad4c","type":"DO","z":"d2db2033.c2624","name":"","epId":"","pin":"16","x":550,"y":240,"wires":[]},{"id":"3191bf6d.8716a","type":"inject","z":"d2db2033.c2624","name":"","topic":"On","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":180,"wires":[["7c612530.efad4c"]]}]
  • Click on the options menu on the top right-hand corner of the screen.
Turn On LED through Internet Pic 9
Magicblocks.io playground interface — Deploy dropdown — import.
  • Next, hover your cursor over the Import sub-menu.
Turn On LED through Internet Pic 10
Magicblocks.io playground interface — Import node to clipboard.
  • Then click on Clipboard and paste the code on your clipboard to the text field
Turn On LED through Internet Pic 11
Import node sub-menu.
  • Select current flow or new flow and click on Import.

IMPORTANT

Make sure you type your device id on the display node properties and type the text you need inside the inject node.

Finally, Deploying the Blocks [Method 1]

1. Connect the inject block with the Digital Out node.

2. Click on the 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 if you click the ‘On’ inject block the LED you chose will turn on, next click on the ‘Off’ inject block to turn it off.

Turn On LED through Internet Pic 12
Deployed sample code block.

To Control All Four LEDs at Once

1. Duplicate the Digital Out block 3 times and assign each block to four LED Pins.

Turn On LED through Internet Pic 13
Sample code deployed successfully.
Turn On LED through Internet Pic 14
Edit Digital Out node.

2. Next connected ‘On’ and ‘Off’ inject blocks with the new Digital Out block.

Turn On LED through Internet Pic 15
Add and edit nodes.

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

4. After deploying click on the box left-side of the inject block to activate it and if you click the ‘On’ inject block the LEDs you chose will turn on, next click on the ‘Off’ inject block to turn it off.

Troubleshooting [Method 1]

  • Check whether it shows connected(or 1/0) below the display block if not recheck the device id which you typed into the display block.
  • Check whether your Magicbit is connected to the internet.

Setting Up the Switch Block [Method 2]

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

Turn On LED through Internet Pic 16
Drag and drop switch block from the dashboard.

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 the payload as 1 and off payload as 0.

Turn On LED through Internet Pic 17
Edit Switch node.

Setting Up the Digital Out Block [Method 2]

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

2. Double-click on the digital out block and type or paste your unique Device ID from the Device Manager Tab on your Magicblocks account. [This will link the digital out block with your Magicbit]

Turn On LED through Internet Pic 18
Edit Digital Out node.

[Optional] Import Already Setup Nodes

  • First copy this code to your clipboard;
[{"id":"f5c6f3ff.5d9a","type":"ui_switch","z":"d2db2033.c2624","name":"","label":"switch","group":"b6e2a4f1.2e9cd8","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":330,"y":700,"wires":[["1bb5fdbe.71ac32"]]},{"id":"1bb5fdbe.71ac32","type":"DO","z":"d2db2033.c2624","name":"","epId":"","pin":"16","x":570,"y":700,"wires":[]},{"id":"b6e2a4f1.2e9cd8","type":"ui_group","z":"","name":"LED","tab":"1e4dddd7.63fc02","disp":true,"width":"10","collapse":false},{"id":"1e4dddd7.63fc02","type":"ui_tab","z":"","name":"Magicbit Tutorial","icon":"dashboard","order":1}]
  • Click on the options menu on the top right-hand corner of the screen.
Turn On LED through Internet Pic 19
Import code from the clipboard.
  • Next, hover your cursor over the Import sub-menu.
Turn On LED through Internet Pic 20
Import code from the clipboard.
  • Then click on Clipboard and paste the code on your clipboard to the text field
Turn On LED through Internet Pic 21
Import note sub-menu.
  • Select current flow or new flow and click on Import.

IMPORTANT

Make sure you type your device ID on the display node properties and type the text you need inside the inject node.

Finally, Deploying the Blocks & Using the Dashboard UI to Access It [Method 2]

  • Connect the Switch block with the Digital Out node.
  • Click on the Deploy button on the top right-hand corner of the screen.
  • After deploying, go to the dashboard UI by clicking the link to the dashboard URL on the top right-hand corner of the screen.
Turn On LED through Internet Pic 22
Click on the URL in the top right corner.
Turn On LED through Internet Pic 23
Click on the URL in the top right corner.
  • Once in the dashboard, you can toggle the switch you just set up on and off to control the LED you assigned to the digital out block.
Turn On LED through Internet Pic 25
Turning on LEDs by a switch.
  • Copy 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 1]

  • Check whether it shows connected(or 1/0) below the digital out block, if not recheck the device ID which you typed into the digital out block.
  • Check whether your Magicbit is connected to the internet.

If you need help or couldn’t understand a step, be sure to check out our YouTube video by clicking here: Youtube Video

Related Posts
Leave a Reply

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