{
 "原理:PWM 為什麼能控制馬達轉速#1": {
  "type": "flow",
  "layout": "row",
  "reveal": [
   0,
   1,
   3
  ],
  "nodes": [
   {
    "label": "開關占一半",
    "sub": "平均水量是全開一半",
    "color": 2
   },
   {
    "label": "開關夠快",
    "sub": "慣性只感覺平均",
    "color": 0
   },
   {
    "label": "PWM",
    "sub": "對馬達做同樣的事",
    "color": 4,
    "kind": "end"
   }
  ]
 },
 "原理:PWM 為什麼能控制馬達轉速#3": {
  "type": "flow",
  "layout": "row",
  "reveal": [
   0,
   0,
   2,
   4,
   4
  ],
  "nodes": [
   {
    "label": "analogWrite",
    "sub": "127",
    "color": 2
   },
   {
    "label": "工作週期",
    "sub": "127 ÷ 255 ≈ 49.8%",
    "color": 0
   },
   {
    "label": "× 電源",
    "sub": "6 V",
    "color": 3
   },
   {
    "label": "平均電壓",
    "sub": "≈ 3.0 V",
    "color": 1,
    "kind": "end"
   }
  ]
 },
 "原理:PWM 為什麼能控制馬達轉速#4": {
  "type": "flow",
  "layout": "row",
  "reveal": [
   0,
   1,
   3,
   4
  ],
  "nodes": [
   {
    "label": "電感與慣性",
    "sub": "擋住瞬間改變",
    "color": 3
   },
   {
    "label": "電氣 τ = L÷R",
    "sub": "2 mH ÷ 3 Ω ≈ 0.67 ms",
    "color": 0
   },
   {
    "label": "機械時間常數",
    "sub": "大得多,數十毫秒",
    "color": 2
   },
   {
    "label": "轉速平穩",
    "sub": "電流小幅起伏",
    "color": 1,
    "kind": "end"
   }
  ]
 },
 "原理:PWM 為什麼能控制馬達轉速#5": {
  "type": "flow",
  "layout": "row",
  "reveal": [
   0,
   2,
   3
  ],
  "nodes": [
   {
    "label": "馬達轉動",
    "color": 2
   },
   {
    "label": "反電動勢 E",
    "sub": "與轉速成正比",
    "color": 4
   },
   {
    "label": "線圈電流 I",
    "sub": "(V − E) ÷ R",
    "color": 0,
    "kind": "end"
   }
  ]
 },
 "原理:PWM 為什麼能控制馬達轉速#7": {
  "type": "bar",
  "unit": " A",
  "labels": [
   "空載電流",
   "堵轉電流"
  ],
  "values": [
   0.2,
   2
  ],
  "highlight": 1,
  "reveal": [
   0,
   1,
   2,
   2
  ]
 },
 "Arduino C++ 基礎:變數、函式與時間#4": {
  "type": "table",
  "head": [
   "型別",
   "說明"
  ],
  "widths": [
   1,
   2.8
  ],
  "reveal": [
   0,
   1,
   2,
   3,
   5
  ],
  "rows": [
   [
    "int",
    "Uno 16 位元、ESP32 32 位元"
   ],
   [
    "unsigned long",
    "用 millis 計時一定要用"
   ],
   [
    "float",
    "Uno 無硬體浮點,較慢"
   ],
   [
    "bool、byte、char",
    "其他常用型別"
   ],
   [
    "const",
    "不變的設定值(腳位、門檻)"
   ]
  ]
 },
 "Arduino C++ 基礎:變數、函式與時間#5": {
  "type": "flow",
  "layout": "row",
  "reveal": [
   0,
   0,
   3,
   3
  ],
  "nodes": [
   {
    "label": "v < lo ?",
    "sub": "回傳 lo",
    "color": 4,
    "kind": "decision"
   },
   {
    "label": "v > hi ?",
    "sub": "回傳 hi",
    "color": 2,
    "kind": "decision"
   },
   {
    "label": "否則",
    "sub": "回傳 v",
    "color": 1,
    "kind": "end"
   }
  ]
 },
 "Arduino C++ 基礎:變數、函式與時間#7": {
  "type": "cards",
  "reveal": [
   0,
   1,
   2,
   2
  ],
  "cards": [
   {
    "title": "delay(500)",
    "points": [
     "卡住整個程式 500 ms",
     "讀不到感測器、聽不到急停"
    ]
   },
   {
    "title": "millis 非阻塞",
    "points": [
     "超過 50 ms 才執行一次",
     "急停每一圈都檢查",
     "now − last 溢位也正確"
    ]
   }
  ]
 },
 "直流馬達、H 橋與 PWM 調速#2": {
  "type": "table",
  "head": [
   "狀態",
   "A 端",
   "B 端",
   "馬達"
  ],
  "widths": [
   1,
   1,
   1,
   1.4
  ],
  "reveal": [
   0,
   3
  ],
  "rows": [
   [
    "正轉",
    "電源",
    "接地",
    "正轉"
   ],
   [
    "反轉",
    "接地",
    "電源",
    "反轉"
   ],
   [
    "停止",
    "接地",
    "接地",
    "停止或煞車"
   ]
  ]
 },
 "直流馬達、H 橋與 PWM 調速#4": {
  "type": "bar",
  "unit": "%",
  "labels": [
   "工作週期 25%",
   "工作週期 50%",
   "工作週期 75%"
  ],
  "values": [
   25,
   50,
   75
  ],
  "max": 100,
  "reveal": [
   0,
   3
  ]
 },
 "直流馬達、H 橋與 PWM 調速#5": {
  "type": "table",
  "head": [
   "馬達",
   "速度腳",
   "方向腳"
  ],
  "widths": [
   1,
   1.2,
   1.8
  ],
  "reveal": [
   0,
   2,
   2
  ],
  "rows": [
   [
    "左馬達",
    "ENA = D5",
    "IN1 = D7、IN2 = D8"
   ],
   [
    "右馬達",
    "ENB = D6",
    "IN3 = D9、IN4 = D10"
   ]
  ]
 },
 "直流馬達、H 橋與 PWM 調速#7": {
  "type": "flow",
  "layout": "row",
  "reveal": [
   0,
   4,
   4,
   4,
   4
  ],
  "nodes": [
   {
    "label": "速度",
    "sub": "−100~100",
    "color": 2
   },
   {
    "label": "換算 PWM",
    "sub": "上限 MAX_PWM 180",
    "color": 0
   },
   {
    "label": "方向腳",
    "sub": "IN1 / IN2",
    "color": 3
   },
   {
    "label": "analogWrite",
    "sub": "速度腳 ENA",
    "color": 1,
    "kind": "end"
   }
  ]
 },
 "Python 邏輯與 Arduino C++ 的對照#2": {
  "type": "table",
  "head": [
   "Python 子集",
   "Arduino C++"
  ],
  "widths": [
   1,
   1
  ],
  "reveal": [
   0,
   0,
   1,
   2
  ],
  "rows": [
   [
    "while True",
    "loop(),自動重複"
   ],
   [
    "設定放在 while 之前",
    "setup()"
   ]
  ]
 },
 "Python 邏輯與 Arduino C++ 的對照#3": {
  "type": "table",
  "head": [
   "Python 子集",
   "Arduino C++"
  ],
  "widths": [
   1,
   1
  ],
  "reveal": [
   0,
   1,
   2,
   3,
   4
  ],
  "rows": [
   [
    "sleep(0.05)",
    "delay(50)"
   ],
   [
    "robot.set_motors(l, r)",
    "setMotors(l, r)"
   ],
   [
    "robot.forward(60)",
    "setMotors(60, 60)"
   ],
   [
    "robot.stop()",
    "setMotors(0, 0)"
   ]
  ]
 },
 "Python 邏輯與 Arduino C++ 的對照#4": {
  "type": "table",
  "head": [
   "Python 子集",
   "Arduino C++"
  ],
  "widths": [
   1,
   1.2
  ],
  "reveal": [
   0,
   1,
   2,
   3,
   4
  ],
  "rows": [
   [
    "robot.distance()",
    "readDistanceCm()"
   ],
   [
    "robot.line()[0]",
    "digitalRead(A0)"
   ],
   [
    "print(f\"x={x}\")",
    "Serial.print / println"
   ],
   [
    "if a and b:",
    "if (a && b) { ... }"
   ]
  ]
 },
 "Python 邏輯與 Arduino C++ 的對照#5": {
  "type": "table",
  "head": [
   "Python 子集",
   "Arduino C++"
  ],
  "widths": [
   1,
   1.3
  ],
  "reveal": [
   0,
   1,
   2,
   3,
   4
  ],
  "rows": [
   [
    "elif / else",
    "else if / else"
   ],
   [
    "for i in range(4):",
    "for (int i = 0; i < 4; i++)"
   ],
   [
    "def f(x): return x*2",
    "int f(int x) { return x * 2; }"
   ],
   [
    "x = x + 1",
    "x = x + 1; 或 x++;"
   ]
  ]
 },
 "Python 邏輯與 Arduino C++ 的對照#6": {
  "type": "table",
  "head": [
   "Python 子集",
   "Arduino C++"
  ],
  "widths": [
   1,
   1
  ],
  "reveal": [
   0,
   1
  ],
  "rows": [
   [
    "# 註解",
    "// 註解"
   ]
  ]
 },
 "Python 邏輯與 Arduino C++ 的對照#7": {
  "type": "flow",
  "layout": "row",
  "reveal": [
   0,
   2,
   4,
   4,
   4
  ],
  "nodes": [
   {
    "label": "speed",
    "sub": "50",
    "color": 2
   },
   {
    "label": "× 255 ÷ 100",
    "sub": "整數運算,小數捨去",
    "color": 0
   },
   {
    "label": "pwm",
    "sub": "127",
    "color": 1
   },
   {
    "label": "map(50, 0, 100, 0, 255)",
    "sub": "結果相同",
    "color": 3,
    "kind": "end"
   }
  ]
 }
}
