Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .github/makecode/blocks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/makecode/blocksdiff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion main.blocks
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
<xml xmlns="https://developers.google.com/blockly/xml"/>
<xml xmlns="https://developers.google.com/blockly/xml"><variables><variable id="O(QFP0]VPg!xA++YIu[T">signal</variable><variable id="[31p3+YI.AYj~G|s!AG9">modo</variable></variables><block type="pxt-on-start" id="JH?a;w!q|9rdnLYMfN6g" x="0" y="0"><statement name="HANDLER"><block type="basic_show_icon" id="LABDi.QEZF@@r]QdoHgL"><field name="i">IconNames.Yes</field><next><block type="device_show_leds" id="UwFcv)8bsu44=VknJz.k"><field name="LEDS">`
. . . . .
. # # # .
. # # # .
. . # . .
. . . . .
`</field><next><block type="radio_set_group" id="()FlE8-_XWP2GHIH{I7L"><value name="ID"><shadow type="math_number_minmax" id="RPbwd25)4?dg,E1i*(#."><mutation min="0" max="255" label="Id" precision="0"/><field name="SLIDER">1</field></shadow></value><next><block type="radio_set_transmit_power" id="mx;~)iL^3D-x|=j_qPGk"><value name="power"><shadow type="math_number_minmax" id=".2!];bpU9WQlR_-q=2iZ"><mutation min="0" max="7" label="Power" precision="0"/><field name="SLIDER">7</field></shadow></value><next><block type="basic_show_icon" id="|w]Q47:},ObhfHU04u,n"><field name="i">IconNames.Heart</field></block></next></block></next></block></next></block></next></block></statement></block><block type="radio_on_string_drag" id="RWus8XsM[9u.`=g)A^rW" x="330" y="-12"><value name="HANDLER_DRAG_PARAM_receivedString"><shadow type="argument_reporter_string" id="2DOHd5RxS0C27-W!*f)n"><field name="VALUE">receivedString</field></shadow></value><statement name="HANDLER"><block type="variables_set" id="`D:+Kqcx95@24$tW}9^6"><field name="VAR" id="O(QFP0]VPg!xA++YIu[T">signal</field><value name="VALUE"><shadow type="math_number" id="4RDLp}Jp(2SK0Hz6`ZJZ"><field name="NUM">0</field></shadow><block type="argument_reporter_string" id="0S.4Mop:(0Q#yeJbII]u"><field name="VALUE">receivedString</field></block></value><next><block type="controls_if" id="`mal2(17y|A?zQr@?tbK"><mutation elseif="2"/><value name="IF0"><shadow type="logic_boolean" id="6Hh/#tE/f2^|%+gfHPvZ"><field name="BOOL">TRUE</field></shadow><block type="logic_compare" id="SGYszq0P5N4xpA,$vZna"><field name="OP">EQ</field><value name="A"><shadow type="math_number" id="*fb{]Df.E[O:R*}50v)i" disabled="true"><field name="NUM">0</field></shadow><block type="string_compare" id="E3sDRYD5^d)d~[+oR@0I"><value name="this"><shadow type="text" id="N*/@3z6J})wyjb,oPMF1" disabled="true"><field name="TEXT">this</field></shadow><block type="variables_get" id="H~3ZUCV!Da|!gk?$GH]F"><field name="VAR" id="O(QFP0]VPg!xA++YIu[T">signal</field></block></value><value name="that"><shadow type="text" id="V~Gw`X1B/1uAR,5rurMt"><field name="TEXT">B1</field></shadow></value></block></value><value name="B"><shadow type="math_number" id="Lhg}tfhvY8ZT-?QK@%yt"><field name="NUM">0</field></shadow></value></block></value><statement name="DO0"><block type="variables_set" id="DrLtop*T1byF(F-EpdCb"><field name="VAR" id="[31p3+YI.AYj~G|s!AG9">modo</field><value name="VALUE"><shadow type="math_number" id="=3uVAOi*w=$HtwPkD9S|"><field name="NUM">0</field></shadow></value></block></statement><value name="IF1"><block type="logic_compare" id="cmG0N(q?,UX3z@G4gyk["><field name="OP">EQ</field><value name="A"><shadow type="math_number" disabled="true"><field name="NUM">0</field></shadow><block type="string_compare" id="`T]ySXG@^?_p+c(}xs9a"><value name="this"><shadow type="text" disabled="true"><field name="TEXT">this</field></shadow><block type="variables_get" id="%I;H~Klic:v*/JkDy4Hm"><field name="VAR" id="O(QFP0]VPg!xA++YIu[T">signal</field></block></value><value name="that"><shadow type="text" id="|R6J}*d,{I(vL_e@5fi$"><field name="TEXT">B2</field></shadow></value></block></value><value name="B"><shadow type="math_number" id="1F~}sTyJ=}U)R=UERU=S"><field name="NUM">0</field></shadow></value></block></value><statement name="DO1"><block type="variables_set" id="X)/5HTi7,o%xC,|_/n,~"><field name="VAR" id="[31p3+YI.AYj~G|s!AG9">modo</field><value name="VALUE"><shadow type="math_number" id="z+FC,rk2_{SXaIRv7nac"><field name="NUM">1</field></shadow></value></block></statement><value name="IF2"><block type="logic_compare" id="vwB/1zizyrxX@,?N3]Mm"><field name="OP">EQ</field><value name="A"><shadow type="math_number" disabled="true"><field name="NUM">0</field></shadow><block type="string_compare" id="RH{WCX3b651/YE3BZP%t"><value name="this"><shadow type="text" disabled="true"><field name="TEXT">this</field></shadow><block type="variables_get" id="@D)}]|e0,CU[PWfG#`wX"><field name="VAR" id="O(QFP0]VPg!xA++YIu[T">signal</field></block></value><value name="that"><shadow type="text" id="UNbu9C+L4kT)64L(ZnY8"><field name="TEXT">B3</field></shadow></value></block></value><value name="B"><shadow type="math_number" id="UNuqgpR)qnGZD#?+b5y{"><field name="NUM">0</field></shadow></value></block></value><statement name="DO2"><block type="variables_set" id="e[qX]WZ`s`saPR^o(5!C"><field name="VAR" id="[31p3+YI.AYj~G|s!AG9">modo</field><value name="VALUE"><shadow type="math_number" id="QaGelM,|q8+:DnQPbqoq"><field name="NUM">2</field></shadow></value></block></statement></block></next></block></statement></block><block type="function_definition" id=".{WU_^RnC#|XZgxZIv7;" x="5" y="576"><mutation name="ModoSeguimiento" functionid="8#.6w1RJ%0JmH;[w[L}6"/><field name="function_name">ModoSeguimiento</field><statement name="STACK"><block type="controls_if" id="SLn$)@q^Gwr#,35J2`R}"><mutation elseif="2" else="1"/><value name="IF0"><shadow type="logic_boolean" id="w,IFs#,8z`hJ9.](FPIQ"><field name="BOOL">TRUE</field></shadow><block type="logic_operation" id="M:wz5y6$,C)-=Cti$*g3"><field name="OP">AND</field><value name="A"><block type="mbit_Line_Sensor" id="W.!?-C^e6{gx-$:n^WEu"><field name="direct">mbit_Robot.enPos.LeftState</field><field name="value">mbit_Robot.enLineState.White</field></block></value><value name="B"><block type="mbit_Line_Sensor" id="TiNj_!/N8Qf-+{-g0#cm"><field name="direct">mbit_Robot.enPos.RightState</field><field name="value">mbit_Robot.enLineState.White</field></block></value></block></value><statement name="DO0"><block type="mbit_CarCtrlSpeed" id="k7$)$34JF9xwkUF$lo:h"><field name="index">mbit_Robot.CarState.Car_Run</field><value name="speed"><shadow type="math_number_minmax" id="wI@4!_Pg|dFb71oIy!}B"><mutation min="0" max="255" label="Speed" precision="0"/><field name="SLIDER">60</field></shadow></value></block></statement><value name="IF1"><block type="logic_operation" id="?mbWm.)p?AUknZ.CD+!L"><field name="OP">AND</field><value name="A"><block type="mbit_Line_Sensor" id="(N2`A*0hj,jH.)fIf[-x"><field name="direct">mbit_Robot.enPos.LeftState</field><field name="value">mbit_Robot.enLineState.White</field></block></value><value name="B"><block type="mbit_Line_Sensor" id="J~yy2./z9PeUF+BHs*)6"><field name="direct">mbit_Robot.enPos.RightState</field><field name="value">mbit_Robot.enLineState.Black</field></block></value></block></value><statement name="DO1"><block type="mbit_CarCtrlSpeed" id="MQT`7#X0z$csAp|`IOD-"><field name="index">mbit_Robot.CarState.Car_SpinRight</field><value name="speed"><shadow type="math_number_minmax" id="uEecPxev9k=Ni{#dR$!:"><mutation min="0" max="255" label="Speed" precision="0"/><field name="SLIDER">70</field></shadow></value></block></statement><value name="IF2"><block type="logic_operation" id="M-x{)y:ckBPW~Swov9SF"><field name="OP">AND</field><value name="A"><block type="mbit_Line_Sensor" id="8F.5e2x#-oUOnyK$.t{n"><field name="direct">mbit_Robot.enPos.LeftState</field><field name="value">mbit_Robot.enLineState.Black</field></block></value><value name="B"><block type="mbit_Line_Sensor" id="mJY@C_7ZT9(n5qhqDg{1"><field name="direct">mbit_Robot.enPos.RightState</field><field name="value">mbit_Robot.enLineState.White</field></block></value></block></value><statement name="DO2"><block type="mbit_CarCtrlSpeed" id="1R]yT1A6rD%HTj=OVfCj"><field name="index">mbit_Robot.CarState.Car_SpinLeft</field><value name="speed"><shadow type="math_number_minmax" id="1-D)T)v:-PUTh?#[5$^U"><mutation min="0" max="255" label="Speed" precision="0"/><field name="SLIDER">70</field></shadow></value></block></statement><statement name="ELSE"><block type="mbit_CarCtrl" id="_;1IN0OP5bTH08(vV~b."><field name="index">mbit_Robot.CarState.Car_Stop</field></block></statement></block></statement></block><block type="function_definition" id="|l6k|+:(;|lXjON,0r0v" x="1300" y="579"><mutation name="ModoManejo" functionid="4,gN[t8eN6LjdV~4`{bv"/><field name="function_name">ModoManejo</field><statement name="STACK"><block type="controls_if" id="K`Q4NuV$oQ*Ii[7){4uh"><mutation elseif="3"/><value name="IF0"><shadow type="logic_boolean" id="KAP~3nkKiW7(z-B:,i.^"><field name="BOOL">TRUE</field></shadow><block type="logic_compare" id="P+vIMmAu~r+l`8pFf=IW"><field name="OP">EQ</field><value name="A"><shadow type="math_number" id="^SWH6U#({OPa(Y*BS_i5"><field name="NUM">0</field></shadow><block type="string_compare" id="9H3@[W}P(}Y]J^s?ft{!"><value name="this"><shadow type="text" id="52LXmKf(/|n7TC!Bq+OL" disabled="true"><field name="TEXT">this</field></shadow><block type="variables_get" id="P{7gpH-8o^A3K7BmN`.R"><field name="VAR" id="O(QFP0]VPg!xA++YIu[T">signal</field></block></value><value name="that"><shadow type="text" id="Ka$!%=1~J`W,P6OL+zX="><field name="TEXT">F</field></shadow></value></block></value><value name="B"><shadow type="math_number" id="Kr%2axuFkB@Vj*|PzG#Y"><field name="NUM">0</field></shadow></value></block></value><statement name="DO0"><block type="mbit_CarCtrl" id="n?2sH}h#54rKq7qk,hU}"><field name="index">mbit_Robot.CarState.Car_Run</field></block></statement><value name="IF1"><block type="logic_compare" id="Vu3y(8ZA0y$!^4eh%?/~"><field name="OP">EQ</field><value name="A"><shadow type="math_number"><field name="NUM">0</field></shadow><block type="string_compare" id="?JYz]YmrC@/q57$i+{#W"><value name="this"><shadow type="text" disabled="true"><field name="TEXT">this</field></shadow><block type="variables_get" id="e?5I@idfxxlAQp@anVNA"><field name="VAR" id="O(QFP0]VPg!xA++YIu[T">signal</field></block></value><value name="that"><shadow type="text" id="-es`chFBxH%kr;R0|`o}"><field name="TEXT">B</field></shadow></value></block></value><value name="B"><shadow type="math_number" id="]16wUS+Q.RQM$IB_L.]N"><field name="NUM">0</field></shadow></value></block></value><statement name="DO1"><block type="mbit_CarCtrl" id="{=Gh3[%)y_*~{_}{l3pm"><field name="index">mbit_Robot.CarState.Car_Back</field></block></statement><value name="IF2"><block type="logic_compare" id="7?ixdf,_4MFV_k:LK0YL"><field name="OP">EQ</field><value name="A"><shadow type="math_number"><field name="NUM">0</field></shadow><block type="string_compare" id="+c#:y@7OL%Q^Rv])lJsG"><value name="this"><shadow type="text" disabled="true"><field name="TEXT">this</field></shadow><block type="variables_get" id="`[{O=K9k;GD*{Cm!2rV2"><field name="VAR" id="O(QFP0]VPg!xA++YIu[T">signal</field></block></value><value name="that"><shadow type="text" id="80|+WU*k[)-9OS0h)k4?"><field name="TEXT">R</field></shadow></value></block></value><value name="B"><shadow type="math_number" id="=7)!U$:9F-KQLG,SvS^G"><field name="NUM">0</field></shadow></value></block></value><statement name="DO2"><block type="mbit_CarCtrl" id="|bWE?d$Pk~8O0^g)}dWp"><field name="index">mbit_Robot.CarState.Car_Right</field></block></statement><value name="IF3"><block type="logic_compare" id="V(@;#*v`LY|po`/gVn~E"><field name="OP">EQ</field><value name="A"><shadow type="math_number"><field name="NUM">0</field></shadow><block type="string_compare" id="7C7TT9Cj3;.GXkiuuq/Z"><value name="this"><shadow type="text" disabled="true"><field name="TEXT">this</field></shadow><block type="variables_get" id="=9A#]YMJO^m%^y?-X=WD"><field name="VAR" id="O(QFP0]VPg!xA++YIu[T">signal</field></block></value><value name="that"><shadow type="text" id="lzvMi!)aBk_:`yt]dA]@"><field name="TEXT">L</field></shadow></value></block></value><value name="B"><shadow type="math_number" id="A/|D9Zwn/,`|yM;{e3Xi"><field name="NUM">0</field></shadow></value></block></value><statement name="DO3"><block type="mbit_CarCtrl" id="%7PexG_N}B={.*EIl;r#"><field name="index">mbit_Robot.CarState.Car_Left</field></block></statement></block></statement></block><block type="function_definition" id="xz+:dURmcFKM6f2W(~xl" x="-4" y="1192"><mutation name="EvitarObjInfrarojo" functionid="=6;K+5I$PLs5aIT!9AbQ"/><field name="function_name">EvitarObjInfrarojo</field><statement name="STACK"><block type="controls_if" id="oqyv`G,#C7hmIp2st:y4"><mutation else="1"/><value name="IF0"><shadow type="logic_boolean" id="Rdea{2wl[i9o08yT`jg,"><field name="BOOL">TRUE</field></shadow><block type="mbit_Avoid_Sensor" id="ginlr_5+E7!3=lQM2uY/"><field name="value">mbit_Robot.enAvoidState.OBSTACLE</field></block></value><statement name="DO0"><block type="mbit_CarCtrlSpeed" id="n{#Vo3N=e,%%!P+;,;*l"><field name="index">mbit_Robot.CarState.Car_SpinLeft</field><value name="speed"><shadow type="math_number_minmax" id="g!oRovB}r69v8PEem8i:"><mutation min="0" max="255" label="Speed" precision="0"/><field name="SLIDER">100</field></shadow></value><next><block type="device_pause" id="x!8o,zz47=^`{K6fv(2n"><value name="pause"><shadow type="timePicker" id="j5z?P{R{24N7^a*G}eUb"><field name="ms">500</field></shadow></value></block></next></block></statement><statement name="ELSE"><block type="mbit_CarCtrlSpeed" id="#RBns$IxR9~_{6(YLgTI"><field name="index">mbit_Robot.CarState.Car_Run</field><value name="speed"><shadow type="math_number_minmax" id="q9@WIvmQ+p$HtO@^r^Iy"><mutation min="0" max="255" label="Speed" precision="0"/><field name="SLIDER">200</field></shadow></value></block></statement></block></statement></block><block type="device_forever" id="N:I=w;4_xc,}cj`3DVz1" x="-2" y="1646"><statement name="HANDLER"><block type="controls_if" id="~!%-kSPf+)g*nEOi_q[f"><mutation elseif="2"/><value name="IF0"><shadow type="logic_boolean" id="RoT!uPm}74m3C}hU#hmT"><field name="BOOL">TRUE</field></shadow><block type="logic_compare" id="z[iOqTcLwjwWbOd-aw@Q"><field name="OP">EQ</field><value name="A"><shadow type="math_number" id=":;YSG^5OHqDUBQ1$h{QI"><field name="NUM">0</field></shadow><block type="variables_get" id="J`dk4Q#H1)+N~11)|p.9"><field name="VAR" id="[31p3+YI.AYj~G|s!AG9">modo</field></block></value><value name="B"><shadow type="math_number" id="o-Iqcya-T4@j0_-W+bPN"><field name="NUM">0</field></shadow></value></block></value><statement name="DO0"><block type="function_call" id="K/BD`MhFFB4[+?ljRS#P"><mutation name="ModoSeguimiento" functionid="8#.6w1RJ%0JmH;[w[L}6"/></block></statement><value name="IF1"><block type="logic_compare" id="%)v),jse1N,I_@ILr!Gt"><field name="OP">EQ</field><value name="A"><shadow type="math_number" id="k52cG]}N2@eyl}gr0O_9" disabled="true"><field name="NUM">0</field></shadow><block type="variables_get" id="0Y1:cLBW%FUXt),YLML@"><field name="VAR" id="[31p3+YI.AYj~G|s!AG9">modo</field></block></value><value name="B"><shadow type="math_number" id="G*DVR.Q@.DG4^:0OzKA^"><field name="NUM">1</field></shadow></value></block></value><statement name="DO1"><block type="function_call" id="/]hv.dbOb{jpUQwa0K2_"><mutation name="ModoManejo" functionid="4,gN[t8eN6LjdV~4`{bv"/></block></statement><value name="IF2"><block type="logic_compare" id="ee}nM-/h:ke#6!uSx+w?"><field name="OP">EQ</field><value name="A"><shadow type="math_number" disabled="true"><field name="NUM">0</field></shadow><block type="variables_get" id="FQj:*_NvlVqU(37/nh47"><field name="VAR" id="[31p3+YI.AYj~G|s!AG9">modo</field></block></value><value name="B"><shadow type="math_number" id="h?@78PoJ7Y5l0X$[d8fo"><field name="NUM">2</field></shadow></value></block></value><statement name="DO2"><block type="function_call" id="gU;*|m*T6p:%U+BN_+1y"><mutation name="EvitarObjInfrarojo" functionid="=6;K+5I$PLs5aIT!9AbQ"/></block></statement></block></statement></block></xml>
68 changes: 58 additions & 10 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,62 @@
radio.onReceivedString(function (receivedString) {
signal = receivedString
if (signal.compare("B1") == 0) {
modo = 0
} else if (signal.compare("B2") == 0) {
modo = 1
} else if (signal.compare("B3") == 0) {
modo = 2
}
})
function EvitarObjInfrarojo () {
if (mbit_Robot.Avoid_Sensor(mbit_Robot.enAvoidState.OBSTACLE)) {
mbit_Robot.CarCtrlSpeed(mbit_Robot.CarState.Car_SpinLeft, 100)
basic.pause(500)
} else {
mbit_Robot.CarCtrlSpeed(mbit_Robot.CarState.Car_Run, 200)
}
}
function ModoManejo () {
if (signal.compare("F") == 0) {
mbit_Robot.CarCtrl(mbit_Robot.CarState.Car_Run)
} else if (signal.compare("B") == 0) {
mbit_Robot.CarCtrl(mbit_Robot.CarState.Car_Back)
} else if (signal.compare("R") == 0) {
mbit_Robot.CarCtrl(mbit_Robot.CarState.Car_Right)
} else if (signal.compare("L") == 0) {
mbit_Robot.CarCtrl(mbit_Robot.CarState.Car_Left)
}
}
function ModoSeguimiento () {
if (mbit_Robot.Line_Sensor(mbit_Robot.enPos.LeftState, mbit_Robot.enLineState.White) && mbit_Robot.Line_Sensor(mbit_Robot.enPos.RightState, mbit_Robot.enLineState.White)) {
mbit_Robot.CarCtrlSpeed(mbit_Robot.CarState.Car_Run, 60)
} else if (mbit_Robot.Line_Sensor(mbit_Robot.enPos.LeftState, mbit_Robot.enLineState.White) && mbit_Robot.Line_Sensor(mbit_Robot.enPos.RightState, mbit_Robot.enLineState.Black)) {
mbit_Robot.CarCtrlSpeed(mbit_Robot.CarState.Car_SpinRight, 70)
} else if (mbit_Robot.Line_Sensor(mbit_Robot.enPos.LeftState, mbit_Robot.enLineState.Black) && mbit_Robot.Line_Sensor(mbit_Robot.enPos.RightState, mbit_Robot.enLineState.White)) {
mbit_Robot.CarCtrlSpeed(mbit_Robot.CarState.Car_SpinLeft, 70)
} else {
mbit_Robot.CarCtrl(mbit_Robot.CarState.Car_Stop)
}
}
let modo = 0
let signal = ""
basic.showIcon(IconNames.Yes)
basic.showLeds(`
. # # # #
# # # . #
# # . # #
# . . # #
. # # # .
`)
basic.showString("HOLA FUNDACION EL NOGAL")
. . . . .
. # # # .
. # # # .
. . # . .
. . . . .
`)
radio.setGroup(1)
radio.setTransmitPower(7)
basic.showIcon(IconNames.Heart)
basic.forever(function on_forever() {

basic.forever(function () {
if (modo == 0) {
ModoSeguimiento()
} else if (modo == 1) {
ModoManejo()
} else if (modo == 2) {
EvitarObjInfrarojo()
}
})
console.log("¡Hola!, soy Yankee")
7 changes: 4 additions & 3 deletions pxt.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "SALUDA",
"name": "Manejo Yankee",
"description": "",
"dependencies": {
"core": "*",
"radio": "*",
"microphone": "*"
"microphone": "*",
"mbit": "github:lzty634158/yahboom_mbit_en#ec0be625edd52ff7e5e0f4bbc92d43cb3c3205d3"
},
"files": [
"main.blocks",
Expand All @@ -26,5 +27,5 @@
"supportedTargets": [
"microbit"
],
"preferredEditor": "tsprj"
"preferredEditor": "blocksprj"
}