ชุดโครงงาน AI ขับรถ
ชุดนี้ต่อ AI ที่หนูสอนเองใน Teachable Machine เข้ากับรถจากบทที่ 16 กล้องของคอมพิวเตอร์ดูการ์ดลูกศรหรือท่ามือ AI ในเบราว์เซอร์เลือกตัวอักษร F L R หรือ S แล้วส่งลงสาย USB ไปให้ Arduino หมุนล้อ AI เป็นสมอง รถเป็นร่างกาย สายเป็นเส้นประสาท และหนูเป็นคนดูผลแล้วเปลี่ยนท่ามือ
English version below · อ่านวิธีทำเต็มๆ ในบทเรียน ระดับ 9
ไฟล์ในชุด
ai-driver.htmlหน้าเว็บสมอง AI มีปุ่ม 1. Connect robot · 2. Start camera · STOP (Esc) ตัวหนังสือบนหน้านี้เป็นภาษาอังกฤษai_driver_car/ai_driver_car.inoโค้ดร่างกายสำหรับ Arduino Uno ของรถจากโครงงานที่ 2 บทที่ 16 ขาและฟังก์ชันdrive()ใช้ตามเดิมai-driver-kit.zipสองไฟล์ข้างบน รวมกับREADME_TH.txtวิธีใช้ฉบับภาษาไทย
- หน้า AI Driver โหลดไลบรารี AI สองตัวจาก cdn.jsdelivr.net คือ TensorFlow.js รุ่น 4.22.0 และ @teachablemachine/image รุ่น 0.8.5 และโหลดโมเดลของหนูจากเซิร์ฟเวอร์ของ Google
- ภาพจากกล้องถูกประมวลผลในเบราว์เซอร์ หน้า AI Driver ไม่ได้อัปโหลดภาพออกไป
- ลิงก์โมเดลที่ได้จาก Upload my model เป็นลิงก์สาธารณะ ใครมีลิงก์ก็ใช้โมเดลได้ จึงสอน AI ด้วยการ์ดลูกศรหรือท่ามือเท่านั้น ห้ามถ่ายหน้าคน
- ระหว่างฝึก Google บอกว่าภาพตัวอย่างอยู่ในคอมพิวเตอร์ของเรา เว้นแต่เลือกบันทึกโปรเจกต์ลง Google Drive
- หน้านี้ที่หนูกำลังอ่านอยู่ไม่มีสคริปต์และไม่ได้ส่งข้อมูลอะไรออกไป
หาซื้ออุปกรณ์ใน Lazada
ปุ่มจะพาไปหน้าค้นหาของ Lazada ในแท็บใหม่ ไม่ได้ผูกกับร้านใดร้านหนึ่ง ให้ผู้ใหญ่เป็นคนเลือกร้านและกดสั่งซื้อ
ง่ายที่สุด ซื้อเป็นชุดรวม ชุดรถเดินตามเส้นราว 550 ถึง 750 บาท อ่านรายการของในกล่องก่อนซื้อ ชุดส่วนใหญ่ไม่มีเซ็นเซอร์ HC-SR04 และสาย USB ยาว และรางถ่านอาจไม่มีสวิตช์ ต้องซื้อเพิ่มจากตารางข้างล่าง
หรือซื้อแยกทีละชิ้น รวมราว 400 ถึง 700 บาท ไม่รวมถ่าน
| ชิ้นส่วน | ราคาโดยประมาณ | ดูให้ดีก่อนซื้อ | ค้นหา |
|---|---|---|---|
| บอร์ด Arduino Uno R3 พร้อมสาย USB | 140 ถึง 220 บาท | บางร้านขายแต่บอร์ด ไม่รวมสาย ดูให้ดีว่ามีสาย USB มาด้วย | Lazada |
| บอร์ดขับมอเตอร์ L298N | 40 ถึง 75 บาท | แผงสีแดง มีครีบระบายความร้อนสีดำ | Lazada |
| โครงรถ 2 ล้อพร้อมมอเตอร์ | 90 ถึง 150 บาท | ต้องมีมอเตอร์เกียร์สีเหลือง 2 ตัว ล้อ 2 ล้อ และล้อหมุนอิสระ ไม่ใช่แผ่นอะคริลิกเปล่า | Lazada |
| โมดูลเซ็นเซอร์ TCRT5000 จำนวน 2 ชิ้น | 20 ถึง 35 บาทต่อชิ้น | เลือกแบบโมดูลที่มีแผงวงจรเล็กและขา 3 ขา ไม่ใช่ตัวเซ็นเซอร์เปล่าราคาไม่กี่บาท และไม่ใช่แบบ 5 ช่อง | Lazada |
| รางถ่าน AA 4 ก้อน แบบมีสวิตช์ | 20 ถึง 45 บาท | ต้องมีสวิตช์เปิดปิด เพื่อตัดไฟได้ทันที | Lazada |
| สายจัมเปอร์ | 15 ถึง 30 บาท | ซื้อทั้งแบบผู้กับเมีย และแบบผู้กับผู้ | Lazada |
| เซ็นเซอร์อัลตราโซนิก HC-SR04 สำหรับโครงงาน 3 บทที่ 16 | 30 ถึง 60 บาท | ถ้าไม่ทำโครงงานหลบสิ่งกีดขวาง ไม่ต้องซื้อ | Lazada |
| สาย USB ยาว 3 เมตร สำหรับโครงงาน AI ขับรถ บทที่ 17 | 20 ถึง 45 บาท | ดูหัวต่อบนบอร์ดก่อน บอร์ดส่วนใหญ่ใช้หัว Type B แต่บางรุ่นใช้ Type-C | Lazada |
ราคาโดยประมาณจากหน้าค้นหาของ Lazada เมื่อเดือนกันยายน 2569 ร้านและราคาเปลี่ยนได้ตลอด ควรเลือกร้านที่มีรีวิวดีและส่งจากในไทย เว็บไซต์นี้ไม่ได้รับค่าตอบแทนจากร้านค้าหรือ Lazada
วิธีเปิดหน้า AI Driver
เบราว์เซอร์ยอมให้ใช้พอร์ตและกล้องเฉพาะหน้าที่ปลอดภัย คือหน้าที่เปิดจาก https หรือจาก localhost
ทางที่ง่ายที่สุด เปิดจากหน้านี้เลย
หน้านี้อยู่บนเว็บที่ขึ้นต้นด้วย https กดปุ่ม เปิดหน้า AI Driver ข้างบนใน Chrome หรือ Edge ได้เลย ไม่ต้องใช้ python และไม่ต้องพิมพ์คำสั่งอะไร
อีกทาง เปิดจากไฟล์ในเครื่อง ผ่าน localhost (ผู้ใหญ่ทำ)
- ดาวน์โหลดไฟล์ zip แล้วแตกไฟล์ไว้ในโฟลเดอร์หนึ่ง
- เปิด Terminal (Mac หรือ Linux) หรือ Command Prompt (Windows) ในโฟลเดอร์ที่มีไฟล์
ai-driver.html - พิมพ์คำสั่งนี้ (บน Windows ถ้าหาคำสั่ง python3 ไม่เจอ ลอง
py -m http.server)python3 -m http.server - เปิด Chrome หรือ Edge ไปที่
http://localhost:8000/ai-driver.html - เล่นเสร็จแล้ว กลับไปที่ Terminal แล้วกด Ctrl + C
ดับเบิลคลิกไฟล์ตรงๆ อาจใช้ได้ใน Chrome แต่ยังไม่ยืนยัน
ใช้ Chrome หรือ Microsoft Edge บนคอมพิวเตอร์ Windows Mac Linux หรือ ChromeOS ใช้ Safari ไอโฟน และไอแพดไม่ได้ Firefox รุ่นใหม่และ Chrome บน Android รุ่นใหม่รองรับแล้ว แต่ยังไม่ได้ทดสอบกับโครงงานนี้ จึงแนะนำให้ใช้คอมพิวเตอร์
- ทำกับผู้ใหญ่ทุกครั้ง
- เล่นบนพื้นเท่านั้น ห้ามบนโต๊ะ
- ใช้ความเร็วต่ำตามโค้ด
- ผู้ใหญ่อยู่ใกล้สวิตช์ถ่านตลอดเวลา
- ทดสอบล้อลอยก่อน
- นิ้วห่างล้อ
- ปิดถ่านก่อนถอดสาย
- ไม่ทิ้งให้รถวิ่งโดยไม่มีคนดู
- เรื่องถ่าน ห้ามใช้ถ่านเก่าปนใหม่ ห้ามลัดวงจร ถอดถ่านเมื่อเล่นเสร็จ
- ใช้ท่ามือหรือการ์ด ไม่ใช้หน้าคน
- ไม่ต่อแบบไร้สายในโครงงานแรก
12 ขั้นแบบย่อ
- ตรวจร่างกายก่อน อัปโหลดโค้ดทดสอบของบทที่ 16 วางรถบนกล่องให้ล้อลอย ดูว่าล้อหมุนเดินหน้าทั้งสองข้าง
- ทำการ์ด 4 ใบ ลูกศรขึ้น ซ้าย ขวา และรูปฝ่ามือ
- สอนตาใน Teachable Machine กลุ่ม Forward Left Right Stop และ Nothing กลุ่มละอย่างน้อย 50 ภาพ ถ่ายแค่การ์ดหรือมือ
- ฝึกแล้วทดสอบในหน้าตัวอย่าง ทุกท่าควรขึ้นถึง 80% อย่างสม่ำเสมอ
- Export แล้ว Upload my model แล้วคัดลอกลิงก์
- ปิดสวิตช์ถ่าน กด Verify แล้ว Upload
ai_driver_car.inoแล้วปิด Serial Monitor - เปิดหน้า AI Driver ใน Chrome หรือ Edge จาก https หรือ localhost
- ล้อลอยอยู่ เปิดสวิตช์ถ่าน กด 1. Connect robot เลือกพอร์ต วางลิงก์ กด 2. Start camera
- ทดสอบความปลอดภัย 8 ข้อตอนล้อลอย ต้องผ่านครบ รวมถึง กด STOP กด Esc และสลับแท็บ ล้อต้องหยุด
- ขับบนพื้นเท่านั้น เคลียร์ที่รอบรถ ไม่มีสัตว์เลี้ยงหรือน้องเล็ก ผู้ใหญ่ถือสายให้หย่อนและอยู่ใกล้สวิตช์ถ่าน ใช้ความเร็วตามโค้ด กด STOP หรือ Esc ได้ทุกเมื่อ
- ทดลองต่อ เช่น เปลี่ยน
THRESHOLDเป็น 0.6 หรือ 0.95 การแก้โค้ดต้องใช้ไฟล์ในเครื่อง ดาวน์โหลดชุดไฟล์ zip แก้ai-driver.htmlด้วยโปรแกรมแก้ข้อความ แล้วเปิดผ่าน localhost ตามอีกทางข้างบน หน้าบนเว็บแก้ไม่ได้ - เก็บของ กด STOP แล้วปิดสวิตช์ถ่าน แล้วถอดสาย USB
รายละเอียด เหตุผลของแต่ละขั้น เกมเรียงขั้น และรายการตรวจที่พิมพ์ได้ อยู่ในบทเรียน ระดับ 9
AI Driver kit
This kit connects an image model that you train yourself in Teachable Machine to the robot car from lesson 16. The computer's webcam looks at an arrow card or a hand sign, the AI in the browser picks one letter (F, L, R or S) and sends it down the USB cable, and the Arduino turns the wheels. The AI is the brain, the car is the body, the cable is the nerve, and you watch the result and change your hand sign.
Full step-by-step guide in the lesson (level 9)
Files
ai-driver.htmlThe AI "brain" page, with the buttons 1. Connect robot · 2. Start camera · STOP (Esc)ai_driver_car/ai_driver_car.inoThe "body" sketch for the Arduino Uno on the lesson 16 car (project 2). Pins anddrive()are unchanged.ai-driver-kit.zipBoth files above plusREADME_TH.txt(instructions in Thai)
- The AI Driver page loads two libraries from cdn.jsdelivr.net, TensorFlow.js 4.22.0 and @teachablemachine/image 0.8.5 (pinned versions), and loads your model from Google's servers.
- Camera frames are processed in the browser. The AI Driver page does not upload them.
- The link you get from "Upload my model" is public: anyone who has it can use the model. Train on arrow cards or hand signs only, never on faces.
- Google says the example photos stay on your computer while you train, unless you choose to save the project to Google Drive.
- This page you are reading has no scripts and sends nothing anywhere.
Buying the parts on Lazada
Each button opens a Lazada search in a new tab and is not tied to any one shop. An adult should choose the shop and place the order.
Easiest: buy a complete kit. A line-follower car kit costs about 550 to 750 baht. Read the list of what is in the box before buying. Most kits have no HC-SR04 sensor and no long USB cable, and the battery holder may have no switch, so add those from the table below.
Or buy the parts one by one. About 400 to 700 baht in total, not counting batteries.
| Part | Approximate price | Check before you buy | Search |
|---|---|---|---|
| Arduino Uno R3 board with USB cable | 140 to 220 baht | Some shops sell the board without the cable, so check that a USB cable is included | Lazada |
| L298N motor driver board | 40 to 75 baht | A red board with a black heatsink | Lazada |
| Two-wheel car chassis with motors | 90 to 150 baht | It must come with 2 yellow gear motors, 2 wheels and a free-spinning caster, not just a bare acrylic plate | Lazada |
| 2 TCRT5000 sensor modules | 20 to 35 baht each | Choose the module with a small circuit board and 3 pins, not the bare sensor that costs a few baht, and not the 5-channel version | Lazada |
| 4 x AA battery holder with a switch | 20 to 45 baht | It must have an on/off switch so you can cut the power at once | Lazada |
| Jumper wires | 15 to 30 baht | Get both male-to-female and male-to-male | Lazada |
| HC-SR04 ultrasonic sensor, for project 3 in Lesson 16 | 30 to 60 baht | You only need it for the obstacle-avoider project | Lazada |
| 3-metre USB cable, for the AI Driver project in Lesson 17 | 20 to 45 baht | Check the socket on your board first: most use Type B, but some use Type-C | Lazada |
Approximate prices from Lazada search pages in September 2026. Shops and prices change all the time. Choose shops with good reviews that ship from within Thailand. This website receives no payment from any shop or from Lazada.
How to open AI Driver
Browsers only allow serial ports and the camera on secure pages: pages opened from https or from localhost.
Easiest: open it from this page
This page is served over https, so just press Open AI Driver above in Chrome or Edge. No Python and no commands needed.
Alternative: run it from your own computer via localhost (adult step)
- Download the zip and unzip it into a folder.
- Open Terminal (Mac or Linux) or Command Prompt (Windows) in the folder that contains
ai-driver.html. - Type this command (on Windows, if
python3is not found, trypy -m http.server):python3 -m http.server - Open
http://localhost:8000/ai-driver.htmlin Chrome or Edge. - When you are done, go back to the terminal and press Ctrl + C.
Double-clicking the file may work in Chrome, but this is not confirmed.
Use Chrome or Microsoft Edge on a Windows, Mac, Linux or ChromeOS computer. Safari, iPhone and iPad do not work. Newer Firefox and newer Chrome on Android support Web Serial, but they have not been tested with this project, so please use a computer.
- Always build and drive with an adult.
- Drive on the floor only, never on a table.
- Keep the low speeds in the code.
- An adult stays next to the battery switch the whole time.
- Test with the wheels lifted first.
- Keep fingers away from the wheels.
- Switch the battery pack off before unplugging the USB cable.
- Never leave the car running with nobody watching.
- Batteries: never mix old and new, never short-circuit them, and take them out when you finish.
- Use hand signs or cards, never faces.
- No wireless connection in your first build.
The 12 steps in short
- Check the body first: upload the lesson 16 test code, put the car on a box with the wheels lifted, and check that both wheels turn forward.
- Make 4 cards: up arrow, left arrow, right arrow and an open palm.
- Teach the eyes in Teachable Machine: classes Forward, Left, Right, Stop and Nothing, at least 50 pictures each, cards or hands only.
- Train, then test in the preview: every sign should reach 80% reliably.
- Export, press Upload my model, and copy the link.
- Battery switch off: Verify, then Upload
ai_driver_car.ino, then close the Serial Monitor. - Open AI Driver in Chrome or Edge from https or localhost.
- Wheels still lifted: switch the battery on, press 1. Connect robot, pick the port, paste the link, press 2. Start camera.
- Run the 8 wheels-lifted safety tests. All must pass, including STOP, Esc and switching tabs (the wheels must stop).
- Drive on the floor only. Clear the area first, with no pets or small children nearby. An adult holds the cable loosely and stays next to the battery switch. Keep the speeds in the code, and press STOP or Esc at any time.
- Experiment, for example change
THRESHOLDto 0.6 or 0.95. Editing the code needs your own copy: download the zip, editai-driver.htmlin a text editor, then open it through localhost (the alternative above). The page on this website cannot be edited. - Pack up: press STOP, switch the battery off, then unplug the USB cable.