# Scratch 實作解法：Auto-Braking Car with LEGO Distance Sensor (LEGO + Scratch)

> 先完成最小可運作版本，確認邏輯正確後再加入美術、音效與關卡變化。 Stop motors automatically when an obstacle is detected nearby.

[繁體中文] LEGO and Scratch physical computing guide: Stop motors automatically when an obstacle is detected nearby.

## 核心觀念與實作步驟: How LEGO Connects to Scratch

先完成最小可運作版本，確認邏輯正確後再加入美術、音效與關卡變化。

Stop motors automatically when an obstacle is detected nearby.

Before starting, confirm Scratch Link (for Bluetooth devices) or USB keyboard input (for Makey Makey) is active on your computer.

- [All 15 Hardware Projects](/zh-tw/hardware/): Explore more micro:bit, LEGO, and Makey Makey ideas.
- [micro:bit Setup Guide](/zh-tw/microbit/): Full Bluetooth and HEX setup instructions.

## 測試檢查與延伸練習

按下綠旗前先預測結果，並觀察變數與座標數值是否符合預期。

- [返回分類總覽](/zh-tw/hardware/): 硬體整合實作（micro:bit / LEGO / Makey Makey）
- [關於 Scratch大全（編輯方針與品質標準）](/zh-tw/about/): 認識 Scratch大全 如何在10種語言中提供系統化的 Scratch 積木辭典、教科書、實作專案與開放教學資料。

## 核心原理解析與 Scratch 3.0 運作機制 — Scratch 實作解法：Auto-Braking Car with LEGO Distance Sensor (LEGO + Scratch)

在 Scratch 3.0（約 30FPS 更新機制）中，掌握變數初始化、迴圈順序與條件觸發時機，能讓作品穩定又容易擴充。

Connecting Scratch to physical sensors, buttons, and motors turns abstract code into tangible STEAM engineering. Before running "Scratch 實作解法：Auto-Braking Car with LEGO Distance Sensor (LEGO + Scratch)", double-check OS compatibility, Bluetooth permissions, Scratch Link status, and fresh batteries to prevent 90% of classroom hardware hiccups.

At its core, "Scratch 實作解法：Auto-Braking Car with LEGO Distance Sensor (LEGO + Scratch)" focuses on this key idea: 先完成最小可運作版本，確認邏輯正確後再加入美術、音效與關卡變化。 Stop motors automatically when an obstacle is detected nearby. In real classroom instruction supervised by Takamasa Suzuki (Okinawa Minecraft Club Programming School "Crosswave", weva.jp), learners progress much faster once they can explain which variable holds state, which event triggers updates, and how the stage resets cleanly on every green-flag click.

Always initialize sprite coordinates, direction, size, visibility, and variables explicitly at project start. A clean initialization sequence eliminates the notorious "you have to click the green flag twice" bug and makes testing predictable across Windows, macOS, Chromebooks, and iPads.

## 三步驟實作法：最小原型、邊界測試與原創延伸

Follow this three-stage workflow to turn "Scratch 實作解法：Auto-Braking Car with LEGO Distance Sensor (LEGO + Scratch)" from a quick example into a polished, bug-free feature inside your own Scratch 3.0 project. Test after every small change instead of stacking 30 blocks at once.

- Stage 1 (Minimal Working Test): Build only the core blocks for "Scratch 實作解法：Auto-Braking Car with LEGO Distance Sensor (LEGO + Scratch)" on a blank sprite and verify that the primary behavior works consistently on the very first green-flag click.
- Stage 2 (Edge-Case & Variable Monitor Check): Turn on stage variable monitors and test boundary cases—zero, negative numbers, stage borders (-240 to 240, -180 to 180), rapid key presses, and clone cleanup.
- Stage 3 (Original Art, Audio & Playtesting): Add custom vector/pixel costumes, balanced sound effects, clear instructions, and invite a friend or family member to playtest without hints so you can spot confusing moments immediately.

## 課堂應用、安全分享與進階路徑（Python / 實體互動）

Mastering "Scratch 實作解法：Auto-Braking Car with LEGO Distance Sensor (LEGO + Scratch)" strengthens math reasoning (coordinates, exterior angles, variables, probability), scientific modeling, and structured debugging. Once comfortable in Scratch 3.0, these exact patterns transfer smoothly into Python, Minecraft MakeCode, Roblox Studio, and web development.

Keep your projects original and safe to share: avoid uploading third-party copyrighted characters or songs, never include real names or personal photos, and write clear Notes and Credits whenever you remix or learn from another creator.

- [Scratch Dictionary](/zh-tw/dictionary/): 硬體整合實作（micro:bit / LEGO / Makey Makey）
- [Scratch Textbook](/zh-tw/textbook/): 在 Scratch 3.0（約 30FPS 更新機制）中，掌握變數初始化、迴圈順序與條件觸發時機，能讓作品穩定又容易擴充。
- [Scratch How-To](/zh-tw/howto/): 三步驟實作法：最小原型、邊界測試與原創延伸

更新日期: 2026-11-25
作者: [鈴木孝昌 (Takamasa Suzuki)](https://scratch.gmnavi.jp/about/author/)
Japanese Edition: https://scratch.gmnavi.jp/hardware/lego-distance-stop/

[Scratch大全 (繁體中文)](https://scratch.gmnavi.jp/zh-tw/)
