• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomeLinkSpriteIOUse IOBlockly with linkSprite.IO
Previous Next

Use IOBlockly with linkSprite.IO

Posted by: Olva , August 2, 2016

Blockly is a completely visual programming language launched by Google in 2012,it is similar to Scratch,a MIT programming language for children.You can build applications with a graphical object,which is a similar way to play Lego blocks toys .

Every graphical object is a block of code and you can joint it together to create a simple function, then combine these functions together to build a program. The whole process only needs to use the mouse to drag, doesn’t need to hit the keyboard.

Blockly is a graphical programming language which runs on Web pages. Users uses the way of drag and drop puzzle to develop applications without writing any code.

图片1

Recently, we use the Blockly editor to implement the remote programming on the equipment which has connected to LinkSpriteIO Cloud. Which means, we can use fully visual programming language to program the IoT equipment and achieve some functions what we want.

图片2

Next we will use the LinkNode D1 as node equipment, then connected it to IOT Cloud of LinkSpriteIO. Blockly Editor will get the button state of the node equipment from LinkSprite IO, and control the LED on the node equipment.

With this example, we will introduce how to use Blockly editor to  program IoT device on LinkSpriteIO.

 

Create a device on LinkSpriteIO

Log in and enter the device list page.

Click the ‘Create DIY Device’ in the upper-right corner to enter the create device page.

Choose the ‘Device Type’ as ‘00’(Custom Device Type).

图片3

Type Device Name and Group Name ,remember the name of the device.

 

After the device is successfully created, create “switch” (button) and “light” (light) two fields (control and judgment status)

图片4

After the success of create device ,click the Blockly in the upper right corner ,enter the programming module of Blockly.

Set the Device that need to be programmed in the Blockly

Click the ‘Web Demo area’ in the upper right corner to choose the exchange page of ‘Web’ and‘Blockly’ .

Change “Choose” into “LinkSpriteIO”that you can get the pages of all the devices.

图片5

Note:You can control the lights on the device page by programming to achieve the synchronization with the LED device.

Select the device that need to be programmed by Group and Device Name, then you can change Blockly into current device and program it.

 

Blockly Graphical Programming

图片6

  1. According to the picture , drag the various modules from the left column to program and interpret program, When the server is connected successfully, then set the led variable to LED property , and set the button to Button property. Query the value of a button every 1s, and when the state is ‘on’ ,  set the led lamp as ‘on’, otherwise set led light as‘off’.  It means that this button’s state will control the LED. Of course, you can also add other logic to achieve the function what you want .

 

2.After complete Blockly programming , you can click the run button  in the upper right corner to run the program.

图片7

Test the result of Programming

1.On the device which you are just created, input the parameter ‘switch’ as 0 or 1,then click the ‘set’ to input the parameters, view the status of the light . Whether to follow switch state change together ?

图片8

Introduce all  modules

图片9

[link]LinkSpriteIO

[Function]Connect with servers

图片10

[link] ‘LinkSpriteIO’-> ‘LED’

[Function]Get the LED light

图片11

[Link]‘LinkSpriteIO’->‘Button’

[Function]Get the‘button’

图片12

[Link]‘LinkSpriteIO’->‘LED’

[Function]Set state of LED as ON/OFF

图片13

[Link]‘LinkSpriteIO’->‘LED’

[Function]What processes will be executed when the state of Led light is on/off.

[Attention]Because this is an operation which is executed immediately after the state of the led have changed , so you can not execute cycle of death or time consuming operation at that time, otherwise the program will enter a state of suspended animation

图片14

[Link]‘LinkSpriteIO’->‘Led’

[Function]Get the state of Led(on/off),to judge the operation,usually it be used with ‘if’ module.

图片15

[Link]‘LinkSpriteIO’->‘led’

[Function]LED light flashing,the number is the time of flashing interval.

图片16

[Link]‘LinkSpriteIO’->‘led’

[Function]Exchange the state of LED light,when the state is ‘on’,change it to ‘off’,otherwise,change it to ‘on’.

图片17

[Link]‘LinkSpriteIO’->‘Button’

[Function]Get the state of button(on/off),to judge the operation,usually it be used with ‘if’ module.

图片18

[Link]‘LinkSpriteIO’->‘Button’

[Function]What processes will be executed when the state of Button is on/off.

[Attention]Because this is an operation which is executed immediately after the state of the Button have changed , so you can not execute cycle of death or time consuming operation at that time, otherwise the program will enter a state of suspended animation

图片19

[Link]“Advanced”->”Delay”

[Function]Cycle operation,once in a while,perform the operation after ‘do’.it is similar to timer,once in a while, execute once.

图片20

[Link]‘Standard’->‘Logic’

[Function]The judgment condition module ‘IF’,if the conditions is established,operating the process after ‘do’.

图片21

图片22

[Link]‘Standard’->‘Logic’

[Function] ‘if..else’Click the set button in the upper right corner of ‘if’module, it will shows as picture,drag ‘else’module or ‘if else’module to under ‘if’module to composed process of ‘if..else’,when the condition was established,then perform the process of ‘if’ or ‘do’,otherwise perform the process after ‘else’.

Change with website

图片5

[Link]Click the‘Web Demo area’ in the upper right corner to choose the exchange page of ‘Web’ and‘Blockly’, then get the pages of all the devices of users.

[Function]Get the page of all the devices of users.

图片23

[Link]‘Web Demo”->”Click Button’

[Function]The control of light.

Share!
Tweet

Olva

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors