Arduino Uno + PlatformIO project for an autonomous robot that navigates the Winter-Olympics style course, drops boxes, follows paths, aligns to target center via color, shoots the ball, and returns.
- Motors: 2x DC with L298N driver
- Servos: claw (pick/drop), shooter (launch)
- Sensors: 2x IR line sensors, HC-SR04 ultrasonic, TCS3200 color sensor
- Control: modular drivers and a simple state machine in
src/main.cpp
- Motor (L298N):
ENA5,IN17,IN28 (Left)ENB6,IN311,IN412 (Right)
- Servos:
Claw9,Shooter10 - IR sensors:
LeftA0,RightA1 - Ultrasonic:
TRIGA2,ECHOA3 - TCS3200:
S02,S13,S24,S313,OUTA4 - Cal button (optional): A5 (INPUT_PULLUP)
cd "/Users/ericx/Documents/PlatformIO/Projects/UTRA Hacks 2026"
platformio run
platformio run -t upload- Open Serial Monitor at 115200 baud.
h: show helpir: print IR analog values (Left/Right)d: print ultrasonic distance (cm)m f/m s/m l: motors forward/stop/slowc o/c c: claw open/closeshoot: fire shooterrgb: raw TCS3200 pulses (lower = brighter)rgbn: normalized 0..255 RGB and classification- Tunables at runtime:
set bs <int>: base speedset tg <int>: turn gainset ib <int>: IR black levelset iw <int>: IR white levelset rmin|rmax|gmin|gmax|bmin|bmax <int>: color calibration ranges
This project aligns to the calibration scheme using pulse widths:
- Raw pulses:
rgbprints R, G, B pulse widths (lower = brighter) - Normalized values:
rgbnmaps pulse ranges to 0..255 (255 = bright) viaConfig::R_MIN/R_MAX,G_MIN/G_MAX,B_MIN/B_MAX. - Update ranges live using
set rmin/rmax/...commands. - Initial ranges set in
include/config.hpp:- R: 44–72, G: 51–121, B: 67–71
- Speeds:
BASE_SPEED,SLOW_SPEED,TURN_GAIN - IR thresholds:
IR_BLACK_LEVEL,IR_WHITE_LEVEL - Ultrasonic stop distance:
OBSTACLE_STOP_CM - Shooter/claw positions:
SHOOT_*,CLAW_*
- Search for box (line follow + ultrasonic stop)
- Pick box (claw close) → drive to blue zone → drop box
- Choose green path → detect rings → sweep to black center
- Shoot ball → back off → return along line
platformio.ini: PlatformIO environmentinclude/pins.hpp: pin assignmentsinclude/config.hpp: tunable parameters + color calibration rangessrc/main.cpp: drivers, state machine, Serial interfacelib/: optional librariestest/: PlatformIO tests (empty by default)
- Secure all wiring; avoid shorts and strain on servo cables.
- Verify motor polarity and servo angles before full-speed tests.
- Ramp approach: prefer
SLOW_SPEEDfor alignment; increase only after stable.