{
 "format": "mbc-project",
 "target": "spike:pybricks",
 "specVersion": 2,
 "meta": {
  "name": "測距者2路 範例5 開到牆前並對正",
  "author": "MBC Robot",
  "createdAt": "2026-10-20T00:00:00.000Z",
  "modifiedAt": "2026-10-20T00:00:00.000Z"
 },
 "board": {
  "fqbn": null,
  "displayName": "LEGO SPIKE Prime"
 },
 "workspace": {
  "blocks": {
   "languageVersion": 0,
   "blocks": [
    {
     "type": "arduino_setup",
     "next": {
      "block": {
       "type": "dev_mbc_laser2__config",
       "fields": {
        "PORT": "C"
       },
       "next": {
        "block": {
         "type": "spike_drivebase_config",
         "fields": {
          "LEFT": "E",
          "LDIR": "ccw",
          "RIGHT": "F",
          "RDIR": "cw",
          "WHEEL": 56,
          "AXLE": 112,
          "GYRO": "N"
         },
         "next": {
          "block": {
           "type": "drive_drive",
           "inputs": {
            "S": {
             "shadow": {
              "type": "math_number",
              "fields": {
               "NUM": 100
              }
             }
            },
            "T": {
             "shadow": {
              "type": "math_number",
              "fields": {
               "NUM": 0
              }
             }
            }
           },
           "next": {
            "block": {
             "type": "ctrl_wait_until",
             "inputs": {
              "COND": {
               "block": {
                "type": "compare_op",
                "fields": {
                 "OP": "LTE"
                },
                "inputs": {
                 "A": {
                  "block": {
                   "type": "dev_mbc_laser2_average",
                   "fields": {
                    "PORT": "C"
                   }
                  }
                 },
                 "B": {
                  "shadow": {
                   "type": "math_number",
                   "fields": {
                    "NUM": 20
                   }
                  }
                 }
                }
               }
              }
             },
             "next": {
              "block": {
               "type": "drive_stop",
               "fields": {
                "HOW": "brake"
               },
               "next": {
                "block": {
                 "type": "ctrl_repeat_until",
                 "inputs": {
                  "COND": {
                   "block": {
                    "type": "compare_op",
                    "fields": {
                     "OP": "LTE"
                    },
                    "inputs": {
                     "A": {
                      "block": {
                       "type": "math_unary_op",
                       "fields": {
                        "OP": "ABS"
                       },
                       "inputs": {
                        "A": {
                         "block": {
                          "type": "dev_mbc_laser2_diff",
                          "fields": {
                           "PORT": "C"
                          }
                         }
                        }
                       }
                      }
                     },
                     "B": {
                      "shadow": {
                       "type": "math_number",
                       "fields": {
                        "NUM": 1
                       }
                      }
                     }
                    }
                   }
                  },
                  "DO": {
                   "block": {
                    "type": "controls_if",
                    "extraState": {
                     "hasElse": true
                    },
                    "inputs": {
                     "IF0": {
                      "block": {
                       "type": "compare_op",
                       "fields": {
                        "OP": "LT"
                       },
                       "inputs": {
                        "A": {
                         "block": {
                          "type": "dev_mbc_laser2_diff",
                          "fields": {
                           "PORT": "C"
                          }
                         }
                        },
                        "B": {
                         "shadow": {
                          "type": "math_number",
                          "fields": {
                           "NUM": 0
                          }
                         }
                        }
                       }
                      }
                     },
                     "DO0": {
                      "block": {
                       "type": "drive_drive",
                       "inputs": {
                        "S": {
                         "shadow": {
                          "type": "math_number",
                          "fields": {
                           "NUM": 0
                          }
                         }
                        },
                        "T": {
                         "shadow": {
                          "type": "math_number",
                          "fields": {
                           "NUM": -30
                          }
                         }
                        }
                       }
                      }
                     },
                     "ELSE": {
                      "block": {
                       "type": "drive_drive",
                       "inputs": {
                        "S": {
                         "shadow": {
                          "type": "math_number",
                          "fields": {
                           "NUM": 0
                          }
                         }
                        },
                        "T": {
                         "shadow": {
                          "type": "math_number",
                          "fields": {
                           "NUM": 30
                          }
                         }
                        }
                       }
                      }
                     }
                    },
                    "next": {
                     "block": {
                      "type": "spike_wait_ms",
                      "inputs": {
                       "MS": {
                        "shadow": {
                         "type": "math_number",
                         "fields": {
                          "NUM": 20
                         }
                        }
                       }
                      }
                     }
                    }
                   }
                  }
                 },
                 "next": {
                  "block": {
                   "type": "drive_stop",
                   "fields": {
                    "HOW": "brake"
                   },
                   "next": {
                    "block": {
                     "type": "hub_beep",
                     "inputs": {
                      "F": {
                       "shadow": {
                        "type": "math_number",
                        "fields": {
                         "NUM": 880
                        }
                       }
                      },
                      "MS": {
                       "shadow": {
                        "type": "math_number",
                        "fields": {
                         "NUM": 500
                        }
                       }
                      }
                     },
                     "next": {
                      "block": {
                       "type": "hub_display_icon",
                       "fields": {
                        "ICON": "HAPPY"
                       }
                      }
                     }
                    }
                   }
                  }
                 }
                }
               }
              }
             }
            }
           }
          }
         }
        }
       }
      }
     },
     "x": 40,
     "y": 90
    }
   ]
  },
  "variables": []
 },
 "variables": [],
 "lastFlashedHash": null
}