-
Notifications
You must be signed in to change notification settings - Fork 286
Open
Labels
Description
As discussed in #54 blink no delay basic example should be possible with ardublockly.
This requires:
- assign pin to variables for easy change in the code
- digital write with the variable
- computation with unsigned long
With additional blocks as present in my branch https://github.com/bmcage/ardublockly it can be done.
Following xml works in Blockly4Arduino (load it up to see in: http://ingegno.be/Manuals/Blockly4Arduino/blockly4Arduino/index_en.html )
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="declare_var_digout" id="6%q8b#n3^N!7c`#)y}`U" x="87" y="38"><field name="NAME">ledPin</field><field name="PIN">13</field><next>
<block type="declare_var_bool" id="|3^6V_K~`#fd?Pkk)cL."><field name="NAME">ledState</field><value name="NUM">
<block type="io_highlow" id="B/oHeJd_fJ(h~~*^=~7V"><field name="STATE">LOW</field></block></value><next>
<block type="declare_var_ulong" id="yU7(UhcFbv6Z3}sn7}vL"><field name="NAME">previousMillis</field><value name="NUM">
<block type="math_number" id="wrp(0:4b{y%lERx/cL~h"><field name="NUM">0</field></block></value><next>
<block type="declare_var_ulong" id="=TvMLKGby{7H|[u[o_6;"><field name="NAME">currentMillis</field><value name="NUM">
<block type="math_number" id="6O*P-9Dn6szKHmKMjQ~3"><field name="NUM">0</field></block></value><next>
<block type="declare_var_ulong" id="%aJ(Vdy~h[Wx`UjBl0BZ"><field name="NAME">interval</field><value name="NUM">
<block type="math_number" id="-v/8VP`FahSD}6BVu6yr"><field name="NUM">1000</field></block></value><next>
<block type="variables_set" id="y1G(O}!ZE;UTc6_}d[/O"><field name="VAR">currentMillis</field><value name="VALUE">
<block type="time_millis" id="V0,v^)PicQdrj]tisWwR"></block></value><next>
<block type="controls_if" id="+Sw.3:D6t2%rz3.m5UIr"><value name="IF0">
<block type="logic_compare" id="56~(M96ko)78n]4*M.pc"><field name="OP">GT</field><value name="A">
<block type="math_arithmetic" id="@n*a0sF`o5R_M^F+|^gY"><field name="OP">MINUS</field><value name="A">
<block type="variables_get" id="m)hW;TfOqir@[5vmDD%S"><field name="VAR">currentMillis</field></block></value><value name="B">
<block type="variables_get" id=":H7J@)N|Wv#CDAG5S,Ie"><field name="VAR">previousMillis</field></block></value></block></value><value name="B">
<block type="variables_get" id="9#g:nhV+8i);wY#a_Ir*"><field name="VAR">interval</field></block></value></block></value><statement name="DO0">
<block type="variables_set" id="=f^o,g=}JP3d_ssRnGe%"><field name="VAR">previousMillis</field><value name="VALUE">
<block type="variables_get" id="{:|daM[[6rFq)%3=HSQk"><field name="VAR">currentMillis</field></block></value><next>
<block type="controls_if" id="X_)_6mR,oodqcNS9|FvK"><mutation else="1"></mutation><value name="IF0">
<block type="logic_compare" id="rqrnlV|M0lk%1*_F2L.%"><field name="OP">EQ</field><value name="A">
<block type="variables_get" id="amfcM9ujj/oyVBhj,*D."><field name="VAR">ledState</field></block></value><value name="B">
<block type="io_highlow" id="@I{N*FxG~{24;Z(Wl:F0"><field name="STATE">LOW</field></block></value></block></value><statement name="DO0">
<block type="variables_set" id="G,pNC9F/#Rt2yIp}Cgvb"><field name="VAR">ledState</field><value name="VALUE">
<block type="io_highlow" id="Zk[?dxVh7F1M~j_.szK5"><field name="STATE">HIGH</field></block></value></block></statement><statement name="ELSE">
<block type="variables_set" id="k_6[XpWhZaH2.pi2t3%["><field name="VAR">ledState</field><value name="VALUE">
<block type="io_highlow" id="3CM!gm6jsoX.~3KM@#?F"><field name="STATE">LOW</field></block></value></block></statement><next>
<block type="io_digitalwrite_var" id="q-!7Oa;Xtvhz|/[rUlnJ"><field name="PIN">ledPin</field><value name="STATE">
<block type="variables_get" id="L)p=4jGTsPZPU4f_%Ydc"><field name="VAR">ledState</field></block></value></block></next></block></next></block></statement></block></next></block></next></block></next></block></next></block></next></block></next></block></xml>
A likewise alternative solution needs to be added to ardublockly in some manner.
carlos edit: list updated with checkboxes for github tracking