diff --git a/.github/makecode/blocks.png b/.github/makecode/blocks.png
new file mode 100644
index 0000000..9c7d7f3
Binary files /dev/null and b/.github/makecode/blocks.png differ
diff --git a/.github/makecode/blocksdiff.png b/.github/makecode/blocksdiff.png
new file mode 100644
index 0000000..e314f93
Binary files /dev/null and b/.github/makecode/blocksdiff.png differ
diff --git a/main.blocks b/main.blocks
index c190d67..fd51637 100644
--- a/main.blocks
+++ b/main.blocks
@@ -1 +1,7 @@
-
\ No newline at end of file
+signalmodoIconNames.Yes`
+ . . . . .
+ . # # # .
+ . # # # .
+ . . # . .
+ . . . . .
+ `17IconNames.HeartreceivedStringsignal0receivedStringTRUEEQ0thissignalB10modo0EQ0thissignalB20modo1EQ0thissignalB30modo2ModoSeguimientoTRUEANDmbit_Robot.enPos.LeftStatembit_Robot.enLineState.Whitembit_Robot.enPos.RightStatembit_Robot.enLineState.Whitembit_Robot.CarState.Car_Run60ANDmbit_Robot.enPos.LeftStatembit_Robot.enLineState.Whitembit_Robot.enPos.RightStatembit_Robot.enLineState.Blackmbit_Robot.CarState.Car_SpinRight70ANDmbit_Robot.enPos.LeftStatembit_Robot.enLineState.Blackmbit_Robot.enPos.RightStatembit_Robot.enLineState.Whitembit_Robot.CarState.Car_SpinLeft70mbit_Robot.CarState.Car_StopModoManejoTRUEEQ0thissignalF0mbit_Robot.CarState.Car_RunEQ0thissignalB0mbit_Robot.CarState.Car_BackEQ0thissignalR0mbit_Robot.CarState.Car_RightEQ0thissignalL0mbit_Robot.CarState.Car_LeftEvitarObjInfrarojoTRUEmbit_Robot.enAvoidState.OBSTACLEmbit_Robot.CarState.Car_SpinLeft100500mbit_Robot.CarState.Car_Run200TRUEEQ0modo0EQ0modo1EQ0modo2
\ No newline at end of file
diff --git a/main.ts b/main.ts
index bf35d53..b9a6d78 100644
--- a/main.ts
+++ b/main.ts
@@ -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")
diff --git a/pxt.json b/pxt.json
index 9219c1f..0a84f98 100644
--- a/pxt.json
+++ b/pxt.json
@@ -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",
@@ -26,5 +27,5 @@
"supportedTargets": [
"microbit"
],
- "preferredEditor": "tsprj"
+ "preferredEditor": "blocksprj"
}