AIToday
Autonomous DrivingAI Coding AssistantsQiita 機械学習Published: Oct 4, 2026, 01:00 JST

PyTorch and Arduino UNO power an end-to-end self-driving toy car

PyTorch and Arduino UNO power an end-to-end self-driving toy car

3 Key Points

  1. What happened

    The author built a palm-sized car where a PC runs a PyTorch CNN (NVIDIA PilotNet, shrunk) that maps camera images to F/L/R/S commands, streamed over Bluetooth to an Arduino UNO.

  2. Why it matters

    The wiring mirrors real vehicles — smartphone as camera, PC as the AI SoC, Arduino as the vehicle-control MCU — and keeps two failsafes off the AI, so the safety design is likely transferable beyond toys.

  3. What to watch

    Whether the trained model actually holds the lane hinges on data balance, since forward dominates the labels and high validation accuracy can hide a car that cannot corner.

WHO IT HITSMakers and robotics hobbyists building small autonomous vehicles, and embedded engineers curious how a PC-to-microcontroller split with independent failsafes is wired, gain a reproducible reference with parts costing a few thousand yen.

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, in your inbox every morning.

Context & Analysis

The system splits work the way a production vehicle does: a heavier AI process runs on a PC (standing in for a vehicle's AI SoC), while a microcontroller (the Arduino UNO, standing in for the vehicle-control MCU) drives the motors. The link between them here is Bluetooth via an HC-05 module rather than automotive CAN or Ethernet. The code ships as four Python files plus one Arduino sketch, and the model is a scaled-down version of NVIDIA's PilotNet that outputs one of three actions: forward, left, or right.

The write-up spends much of its space on pitfalls the author hit. Latency stacks up at every seam — camera, Wi-Fi, inference, Bluetooth, Arduino — and two causes are easy to miss: OpenCV buffering old frames, and the blocking pulseIn() call on the ultrasonic sensor, whose default timeout can stall the whole control loop unless shortened. The PulseIn timeout is set to 25ms. The author also notes that changing room lighting between data collection and driving degrades the model, and that ColorJitter during training helps.

The stakes here are less about this particular toy than about the pattern it demonstrates: pushing AI decisions across a laggy link to physical motors surfaces the same structural difficulty whether the vehicle is palm-sized or full-scale. The author's stated principle is that placing failsafes on a lower-level microcontroller, independent of the AI, holds for both. What this hinges on for anyone replicating it is likely the quality and balance of the collected driving data, since a model can post good accuracy numbers while still failing to steer through a curve. The article states the parts cost a few thousand yen.

FAQ
What safety features keep the car from running away?
The Arduino UNO has two failsafes independent of the AI: it force-stops if the HC-SR04 ultrasonic sensor sees anything within 20cm, and it stops if no command arrives for 0.3 seconds (a watchdog).
What hardware does the project use?
It uses an Arduino UNO R3, a PC (faster training with a GPU), a smartphone with the IP Webcam app, an HC-SR04 ultrasonic sensor, an HC-05 Bluetooth module, and an L298N motor driver with two DC motors powered by four AA batteries.
Qiita 機械学習Read Original Article

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Related Articles

Next articleSplice CEO Kakul Srivastava warns AI emails kill real talk