Overview & Philosophy
Conceived during Year 8 for a school ICT project assignment and engineered over several months into Year 9, AI RC Car marked my first serious, long-term engineering undertaking. My goal was to look far past standard classroom tutorials and prove what a student can build—even without formal engineering credentials—when given prototyping tools, curiosity, and persistence.
Rather than squeezing wireless communication, LCD rendering, motor stepping, and vision processing onto a single microcontroller, I architected a distributed 4-MCU computing bus communicating over a custom-designed 2-byte I²C serialization protocol. Built around a 3-wheel layout with dual front-wheel bipolar stepper motors (chosen over conventional DC motors for deterministic precision) and a rear swivel caster salvaged from a broken roller chair, the robot integrates a HuskyLens edge AI camera inside a 2-DOF thrust-bearing gimbal, an on-demand 18 V / 24 V relay-switched voltage booster (doubling external pulling force from ~1 kg to ~2 kg despite the heavy chassis), and two-part 3D-printed PLA wheels fitted with flexible TPU climbing treads. Every structural part was modeled in Autodesk Inventor and AutoCAD, 3D printed, and fastened with screws—while every UI icon and panel in its companion MIT App Inventor Bluetooth app was designed from scratch in Adobe Photoshop. The completed vehicle earned an Innovation Certificate from Providence English Private School in Year 9C on June 7, 2023, and was subsequently gifted to the school.
Distributed 4-MCU Architecture & Custom I²C Protocol
Coordinating Bluetooth telemetry, pulse-timed stepper stepping, ultrasonic ranging, character LCD redraws, and camera tracking loops without stalling time-critical motor pulses required splitting responsibilities across four microcontrollers sharing a synchronized I²C bus:
- Wireless Gateway (
ESP32—AI_Robot_Bluetooth_Communication_V3.ino, I²C Master): Receives asynchronousTouchDown/TouchUpcommands overBluetoothSerialfrom the Android tablet/smartphone app, maps incoming command codes ("11"–"19"), and broadcasts 2-byte control frames across the shared I²C bus. - Primary Motion Hub (
Arduino Mega 2560 #1,SLAVE_ADDR = 9—StepperMotors-2.0.ino): Executes the core drive state machine (Manual_Mode,Follow,Mode_Switch), drives both front-wheel bipolar steppers viaAccelStepper(FULL4WIRE, pins2–9,1100 steps/snominal) through dualL298NH-bridges, and manages the four mode-switching relays (22, 24, 26, 28). - Booster & Display Controller (
Arduino Mega 2560 #2,Booster_ADDR = 10—BoosterAndDisplay_Controller.ino): Manages the16×2character LCD (driving contrast directly via software PWM duty cycle60without a physical potentiometer), stores the configurable following-distance setpoint (Wire.requestFrom(Booster_ADDR, 1)), and triggers the dual-relay12 V → 18 Vvoltage booster for a 10-second thermal window with a200 msbreak-before-make relay delay so the 12 V and boosted rails can never short together. - AI Vision & Sensor Fusion Engine (
Arduino Uno—Huskylens_processor.ino): Polls theHuskyLenscamera overSoftwareSerial(9600 baud, pins10/11) and the frontHC-SR04ultrasonic sensor (NewPingon pins2/3), estimates target distance and320 × 240pixel center offsets, and dispatches differential follow commands (Addr 9) plus signed servo angle deltas (Servo_Runner = 11).
Because standard Arduino Wire streams raw bytes without typed packet framing, I built a decimal-tagged 16-bit integer encoding scheme (packet = (payload * 10) + tag, transmitted as highByte / lowByte). On receipt inside receiveEvent(), each listener reconstructs the 16-bit integer, switches on Data_Recieved % 10 (0 = Button, 1 = BarX, 2 = BarY, 3 = Width, 4 = Height, 5 = AI_SEE, 6 = Distance_Space, 7 = Angle), and extracts the original value via integer division by 10:
void receiveEvent() {
// Read while data received
Data_Recieved_High = Wire.read();
Data_Recieved_Low = Wire.read();
Data_Recieved = (Data_Recieved_High << 8) | Data_Recieved_Low;
Serial.println("----------------");
Serial.print("Data Recieved: ");
Serial.println(Data_Recieved);
if((Data_Recieved % 10 ) == Button_Transfer){
Button_Condition = floor(Data_Recieved / 10);
Serial.print("Button Condition: ");
Serial.println(Button_Condition);
}
if((Data_Recieved % 10 ) == BarX_Transfer){
BarX = floor(Data_Recieved / 10);
Serial.print("BarX: ");
Serial.println(BarX);
}
if((Data_Recieved % 10 ) == BarY_Transfer){
BarY = floor(Data_Recieved / 10);
Serial.print("BarY: ");
Serial.println(BarY);
}Tech Stack & Mechanical Engineering
Hardware & Power Electronics
- Distributed Compute:
ESP32Bluetooth master, dualArduino Mega 2560control/booster hubs, and anArduino Unodedicated to vision and ultrasonic sensor fusion. All5 Vlogic power is sourced directly from the Arduino board pins (no separate isolated 5 V buck regulator). - Actuation & Drivers: 3-wheel configuration featuring dual front-wheel drive bipolar stepper motors driven by dual
L298NH-bridge modules (1100 steps/sdrive,3000 steps/sceiling), a rear swivel caster wheel salvaged from a broken roller chair, and dual analog servos on the 2-DOF camera turret. - Switched High-Voltage Power Stage: Originally powered by a heavy
12 V 7 Alead-acid battery and later upgraded to a12 V 20 ALithium-Ion battery pack to satisfy continuous stepper current demands; routed through a single5 Aadjustable DC-DC step-up boost converter (stepping12 V → 18 V, engineered to scale to24 V) switched by two low-voltage trigger relays with a200 msbreak-before-make safety delay and10 sactive window—doubling external pulling capacity from ~1 kg unboosted to ~2 kg boosted. - Sensors & Interface:
DFRobot HuskyLensAI vision sensor (320 × 240facial recognition & tracking viaSoftwareSerial),HC-SR04front ultrasonic rangefinder, and a backlit16×2character LCD with software PWM contrast (60) displaying live operating mode (Manual Modevs.AI Mode).
Mechanical CAD & 3D Fabrication
- All-Screwed 3D-Printed Chassis (
Autodesk Inventor&AutoCAD): Every structural housing and multi-tier electronics bay was modeled from scratch, 3D printed, and fastened strictly with machine screws rather than adhesives. - Two-Segment Hybrid Climbing Wheels (
PLA+TPU): Each drive wheel pairs a rigid PLA inner hub with a uniquely designed TPU outer tread featuring flexible teeth-like flaps, engineered specifically to deform for grip and climb steep surfaces. - Thrust-Bearing Camera Gimbal: Upper 2-DOF pan/tilt cage resting on a physical steel ball thrust bearing, offloading axial turret weight from the pan servo shaft for smooth horizontal tracking.
Software & Toolchains
- Embedded C++ (
Arduino IDE):Wire.h,AccelStepper.h,NewPing.h,Servo.h,LiquidCrystal.h,SoftwareSerial.h,BluetoothSerial, andHUSKYLENS.h. - Companion App & Custom Graphics: Event-driven MIT App Inventor Bluetooth controller where every graphic, button frame, directional arrow, and flame booster icon was designed from scratch in Adobe Photoshop.
Autonomous AI Vision, Distance Fusion & 2-DOF Gimbal Tracking
When switched into AI Mode, Huskylens_processor.ino combines monocular computer vision with physical ultrasonic ranging so the robot locks onto a target person's face, rotates its 2-DOF camera turret to keep them centered, and drives forward or backward to maintain the operator's chosen following distance (Distance_Space, defaulting to 40 cm with a ±20 cm deadzone):
- Monocular Bounding-Box Distance Estimation (
Find_Camera_Distance()): Approximates visual range in centimeters by comparing the detected face bounding area (BarX_Width * BarY_Height) against an empirically calibrated reference face block (146 × 109 px, scale constant14.09), cross-checking it withHC-SR04pings before commandingForward_ON_Move()orBackward_ON_Move():
- Proportional Gimbal Centering (
X_Track_Servos()): Computes pixel displacement from the320 × 240optical center, converts pixels to angular deltas while ignoring noise inside a±5°deadband, and packs positive or negative correction packets to the gimbal slave node so the camera stays locked even when the chassis is stationary:
The following snippet from Huskylens_processor.ino implements that pan-axis angular error calculation and transmits signed decimal-tagged correction frames to the servo controller over I²C:
void X_Track_Servos() {
//Servo_Angle_X = map(BarX, 0, 640, 180, 0); // 320
float Pixel_To_Angle_Factor = (180 / (X_Screen + 40)) / 3;
float Pixel_To_Center_Point_Difference = BarX - (X_Screen/2);
float Correction_Deadzone = 5; //Unit in degrees
Servo_Angle_X_Correction = (Pixel_To_Center_Point_Difference * Pixel_To_Angle_Factor) * -1;
Wire.requestFrom(Servo_Runner, 1);
while(Wire.available()){
Servo_Angle_X = Wire.read();
}
if((Servo_Angle_X_Correction > Correction_Deadzone || Servo_Angle_X_Correction < (Correction_Deadzone * -1)) && AI_SEE == 2){
if(Servo_Angle_X_Correction != Servo_Angle_X_Correction_State){
//if(Servo_Angle_X_Correction > 0) Servo_Angle_X += 5;
//if(Servo_Angle_X_Correction < 0) Servo_Angle_X -= 5;
//Servo_Angle_X = Servo_Angle_X + Servo_Angle_X_Correction;
}
if(Servo_Angle_X > 180 || Servo_Angle_X < 0) Servo_Angle_X = 90;
if(Servo_Angle_X_Correction > 0) {
Wire.beginTransmission(Servo_Runner);
Wire.write(highByte(((((int(Servo_Angle_X_Correction)) * 10) + X_Correction_Positive_Transfer)*10) + Angle_Transfer));
Wire.write(lowByte(((((int(Servo_Angle_X_Correction)) * 10) + X_Correction_Positive_Transfer)*10) + Angle_Transfer));
Wire.endTransmission();
//delay(15);
}In parallel, Follow() compares both the ultrasonic rangefinder and the camera-derived range (Object_Distance) against the operator-tuned Distance_Space target—synchronizing state edges (Forward_State, Backward_State, Stop_State) over I²C so the stepper controller never receives redundant motion bursts while a subject stands still. When vision lock flips between searching (AI_SEE = 1) and locked (AI_SEE = 2), Servo_AI_SEE() immediately notifies the gimbal controller via an edge-triggered I²C update alongside the monocular distance calculation:
void Find_Camera_Distance(){
int Area_Of_Biggest_Block = 146 * 109; // Greatest possible face block area
int Area_Of_Block = BarX_Width * BarY_Height; // Finding Area of block
float Distance_Factor = 14.09; //Previously calculated Dista nce factor
Object_Distance = ((Area_Of_Biggest_Block / Area_Of_Block) / Distance_Factor) * 100; //Note we are also converting this to centimeter
}
void Servo_AI_SEE(){
if(AI_SEE == 2 && AI_SEE_STATE == 0){
Wire.beginTransmission(Servo_Runner);
Wire.write(highByte((AI_SEE * 10) + AI_SEE_Transfer));
Wire.write(lowByte((AI_SEE * 10) + AI_SEE_Transfer));
Wire.endTransmission();
AI_SEE_STATE = 1;
}
if(AI_SEE == 1 && AI_SEE_STATE == 1){
Wire.beginTransmission(Servo_Runner);
Wire.write(highByte((AI_SEE * 10) + AI_SEE_Transfer));
Wire.write(lowByte((AI_SEE * 10) + AI_SEE_Transfer));
Wire.endTransmission();
AI_SEE_STATE = 0;
}
}Custom MIT App Inventor Bluetooth Cockpit
To operate both manual driving and autonomous AI tracking wirelessly, I built a custom MIT App Inventor Android interface paired over Bluetooth to the ESP32 gateway, with every visual element, icon, and neon-green panel crafted from scratch in Adobe Photoshop:
- Event-Driven
TouchDown/TouchUpControl Matrix: Uses pairedBluetoothClient1.SendTextevents so the car moves strictly while held and halts instantaneously upon finger release—mappingUp("11"/"12"),Down("13"/"14"),Left("15"/"16"),Right("17"/"18"), and in-place rotational spin buttons intoButton_Conditionstates on the ESP32. - AI Mode & 10-Second Booster Trigger: Dedicated top-right
AI Modetoggle switching the vehicle and16×2 LCDbetween Manual and Autonomous Vision modes (13/14), paired with the bottom-left custom flame Booster Button ("19") that initiates the 10-second18 Vrelay boost cycle with its200 msbreak-before-make transition. - Live Following-Distance Adjuster:
10 cm +and10 cm -controls (Button_Condition15/17) dynamically updating theSpace Distance AItarget stored onBooster_ADDR = 10and polled by the Arduino Uno vision loop.
Challenges & Lessons Learned
Stepper Holding Torque, Lead-Acid Weight & Break-Before-Make Boosting
Unlike brushed DC motors, bipolar steppers draw heavy continuous current even at low RPM—causing the original 12 V 7 A lead-acid battery to add massive dead weight while sagging under climb loads. Upgrading to a 12 V 20 A Li-Ion battery pack, adding the relay-switched 5 A DC-DC step-up booster (12 V → 18 V, doubling external pulling capacity from ~1 kg to ~2 kg) guarded by a 200 ms break-before-make relay delay and 10-second thermal window, and calling disableOutputs() in StepperMotors-2.0.ino whenever idle resolved both voltage rail safety and stalled starts.
Multi-MCU I²C Bus Framing & Contention
Splitting tasks across four microcontrollers introduced race conditions and 16-bit framing headaches on Arduino's Wire library. Developing a deterministic decimal-digit tag protocol (% 10 routing), enforcing a 1000 ms Wire.setTimeout(), and caching edge states (Forward_State, AI_SEE_STATE) eliminated duplicate transmissions and prevented slow ultrasonic pings or LCD refreshes from stuttering the step pulses.
Isolating Radial & Axial Loads on the 2-DOF Gimbal
Mounting the HuskyLens housing directly onto a micro-servo horn quickly bound the gears under the weight of the cage and dual-axis wiring harness. Designing a pocketed seat around a steel ball thrust bearing directly beneath the panning turret decoupled vertical compressive load from the servo spline, giving the gimbal crisp horizontal sweeps—a mechanical lesson that carried straight into later competition robots.
Why This Build Mattered
Everything learned building a 4-MCU robot starting in Year 8—interrupt-safe actuation, bus contention, break-before-make power switching, sensor deadbands, and mechanical load isolation—became the baseline for later architectures: consolidating parallel tasks onto ESP32 FreeRTOS cores in MazeBot and squeezing a deterministic 100 Hz multi-rate scheduler into 99.7% of a single ATmega328P in 1st-place ALFRED.

