VEXCODE V5 · SINGLE-FILE SETUP · INTERNAL

VEXcode V5 Setup Guide

πŸ—ΊοΈ Flowchart β€” VEXcode V5 install β€” first-time setup

VEXcode is the easier path for new students. Free, no terminal needed, runs the same V5 hardware.

flowchart TD
    Start([New laptop or new student]) --> Dl[Download VEXcode V5
code.vex.com/v5] Dl --> Install[Install the app
verify: opens and shows splash] Install --> Connect[Connect V5 Brain via USB
verify: VEXcode detects it] Connect --> Project[File β†’ New Project
pick template:
Path B Spartan template] Project --> Build[Build button
verify: green check appears] Build --> Upload[Upload to Brain
verify: progress bar completes] Upload --> Q1{Runs on Brain?} Q1 -->|"Yes"| Done([VEXcode ready]) Q1 -->|"No"| Debug[Diagnose:
cable? Brain firmware up to date?
VEXcode app up to date?] Debug --> Build style Start fill:#1e293b,stroke:#22d3ee,stroke-width:2px,color:#e2e8f0 style Done fill:#1e293b,stroke:#22c55e,stroke-width:2px,color:#e2e8f0 style Q1 fill:#fbbf24,color:#0f172a,stroke:#fbbf24

Import a Spartan reference project into a new VEXcode V5 C++ project. Recommended: the single-file edition that works inside the standalone VEXcode V5 IDE. Multi-file via VS Code Extension covered in the appendix.

⚡ SHORTCUT · Skip the paste step
Want to skip the setup entirely and jump straight to calibrating? Download Clawbot_2822_SmartDrive.v5cpp — open it in VEXcode V5 via File → Open Project and you'll have the working Spartan Clawbot project with all sensors configured, all session fixes baked in, ready to build and calibrate. Skip Steps 1-5 below.

WHICH ONEWhich version do I download?

If you use...Download...Architecture is...
VEXcode V5 standalone IDE
Blocks + Text — the simple app
Single-file edition
<robot>-vexcode-single.zip
Preserved as banner-commented sections inside one big main.cpp
VEX VS Code Extension
VEX's official multi-file path
Multi-file edition
<robot>-vexcode-project.zip
Full architecture — separate arm.cpp, claw.cpp, etc.

This guide covers the single-file workflow. Multi-file via VS Code Extension is covered in the appendix at the bottom of the page.

PRE-FLIGHTWhat you need

STEP 1Create a fresh C++ project

  1. Open VEXcode V5
  2. File → New Text Project
  3. Choose C++ when prompted
  4. Use the Empty Project template (NOT "Clawbot Drivetrain" or any template that pre-configures devices)
  5. File → Save As, give it a name (e.g., Clawbot-2822)
⚠ Important: Empty Project is required. Templates like "Clawbot Drivetrain" pre-configure devices with names that conflict with the reference's expected names. Start from a blank slate.

STEP 2Configure devices in the wizard

The reference code is Path A — hardware comes from the Devices wizard, not from code declarations. Before you paste the reference, configure all required devices in the Devices panel (left sidebar of VEXcode V5).

  1. Open the Devices panel (left sidebar)
  2. Click Add a Device for each device needed by your reference project
  3. Use the exact device names listed in the reference's pragma region (top of main.cpp)
The per-project device checklist with exact names, ports, and settings is at spartandesignrobotics.org/vexcode-devices-setup. Open that page in another tab and use it as your guide.
Skip this step entirely by downloading Clawbot_2822_SmartDrive.v5cpp and using File → Open Project. That project file ships with all devices pre-configured. Then skip to Step 4 (Build).

STEP 3Open the reference main.cpp

Unzip the downloaded reference (e.g., clawbot-vexcode-single.zip). Inside you'll find one file: main.cpp (plus a README). Open main.cpp in any plain-text editor — Notepad on Windows, TextEdit on Mac, or anything similar.

STEP 3.5Replace VEXcode's default main.cpp

  1. In VEXcode, click into the main.cpp file
  2. Select all (Ctrl+A / Cmd+A)
  3. Delete (so the file is empty)
  4. Switch back to the reference main.cpp in your text editor
  5. Select all → copy (Ctrl+C / Cmd+C)
  6. Switch to VEXcode → pastesave (Ctrl+S / Cmd+S)
About the #pragma region at the top: reference files start with two #pragma lines wrapping an empty region. This is the space VEXcode V5's Devices wizard uses to inject auto-generated device code when you add hardware via the GUI. Path B doesn't use the wizard, so the region is empty — but keeping the pragma lines means students can still add sensors via the GUI later (the AI Vision Sensor's color training, for instance, is GUI-only). If you ever do strip them, the Devices wizard refuses to add devices until the markers are restored. Just paste the whole reference file and they come along.

STEP 4Build

Click the Build button (hammer icon or Ctrl+F5 / Cmd+B). Watch the output panel. If the build succeeds → skip to Step 5. If it fails → the first error in the output is the real problem.

Troubleshooting

ErrorFix
redefinition of 'Brain' VEXcode's Empty Project template auto-declares Brain in robot-config.cpp, so the reference's brain Brain; line in Section 1 must stay commented out (default). If you accidentally uncommented it, re-comment it. If you used a template that doesn't auto-declare Brain (rare), uncomment the line.
Devices wizard won't add a sensor, or build fails right after Devices changes You may have deleted the #pragma region VEXcode Generated Robot Configuration lines at the top during paste. The Devices wizard needs these markers to know where to inject auto-generated code. Re-paste the whole reference file (which includes the pragma block) or manually add a matching #pragma region / #pragma endregion pair at line 1.
no member 'spinToPosition' or 'motor_group' VEXcode SDK is too old. Update via Help → Check for Updates. You need 3.x or newer.
'LeftDriveA' already declared (or similar) You started from a Devices-configured template. Restart with File → New Text Project → C++ using a plain template.
IMU calibration hangs forever Section 1 of main.cpp — the IMU port must match your wiring (Clawbot=11, Flex=13, Skimmer=8).
no matching member function for call to 'spinToPosition' Fixed in current zips. If you have an older zip, the Claw.spinToPosition(...) calls have 5 arguments — replace with 3-arg form: Claw.spinToPosition(POSITION, degrees, false). Then add Claw.setVelocity(CLAW_SPEED, percent); to claw_init(). Or just re-download the latest zip.
Motors spin wrong direction Section 1 of main.cpp — change the third argument of the motor() constructor (true = reversed, false = normal).

STEP 5Download to the robot

  1. Connect V5 brain via USB cable (or controller-to-brain VEXnet)
  2. Brain icon at the top of VEXcode turns green
  3. Pick a slot from the dropdown (default: slot 1)
  4. Click Download (arrow icon)
  5. Press Run on the brain to start
✓ What you should see: after Run, the brain shows the auton selector menu. Press UP/DOWN on the controller to cycle through autons, A to confirm. The selector exits and the brain reads Ready — the robot is now waiting for match start (or you can drive manually for testing).

UNDERSTANDINGThe single-file structure

The reference main.cpp isn't a 600-line mess — it's organized into clearly-named SECTIONS separated by big banner comments. Each section is what would be a separate file in a multi-file project. Use Find (Ctrl+F) to jump to a section by its banner.

SectionContents
1. HARDWAREMotor / sensor / pneumatic definitions (was robot-config.cpp) — edit ports here
2. FORWARD DECLSFunction signatures so code can call functions defined later in the file
3+. SUBSYSTEMSOne section per mechanism — arm, claw, lift, intake, tube, pneumatics. Tunable constants at top, then init / control / auton API functions
AUTONSDrive helpers + per-auton routines
AUTON SELECTORBrain-screen selector (~30 lines — VEXcode doesn't ship one)
MAINpre_auton(), autonomous(), usercontrol(), main() — pure orchestration

TUNINGWhat to edit after a successful build

  1. Port assignments. Section 1 of main.cpp. The port numbers in motor constructors must match your wiring. This is the only section you need to edit for port changes.
  2. Mechanism constants. Each subsystem section has tunable values at the top (ARM_POWER = 80, CLAW_OPEN_DEG = 200, etc.). Find the section banner, the constants are right below.
  3. Autons. The drive_for_ms(power, ms) helper needs calibration for your wheel size and gearing. Run auton_drive_test and measure actual distance.
  4. Read the architecture page. Full reference at spartandesignrobotics.org/code-architecture-vexcode.

APPENDIXMulti-file via VS Code Extension

When students outgrow the single-file edition and want the full multi-file architecture — one .cpp per mechanism, compiler-enforced encapsulation — the path is the VEX VS Code Extension. This is NOT the same as the PROS + EZ-Template setup students struggled with.

Why VEX VS Code Extension is different from PROS + VS Code
AspectPROS + EZ-Template (painful)VEX VS Code Extension (simple)
InstallVS Code + PROS CLI + library imports + makefile configVS Code + one click for the VEX extension
Terminal commands?Yes — pros, make, library managementNone
New project flowCLI command + template + manual filesSidebar → New Project → V5 → C++
Build / DownloadTerminal or tiny grey iconBig buttons in the sidebar
Devices panelNoneBuilt-in graphical port config
Multi-file C++Yes (with Makefile editing)Yes (src/ + include/ folders just work)
Upgrade path: when ready to switch to multi-file
  1. Install VS Code (from code.visualstudio.com)
  2. In VS Code: install the VEX Robotics extension (Ctrl+Shift+X, search "VEX")
  3. New Project → V5 → C++ → Empty Project
  4. Download the multi-file reference (<robot>-vexcode-project.zip) instead of single-file
  5. Copy src/*.cpp + include/*.h into the matching folders
  6. Build + Download via the VEX sidebar buttons

The internal architecture (init/control split, file-scope state, auton API) is identical between single-file and multi-file editions — only the file separation changes. Migration is mechanical: each SECTION becomes a separate .cpp + .h file.

RESOURCESCompanion references

PRIMARY
VEXcode Architecture
Full pattern reference with code blocks, 3 robot examples, migration guide
FULL WALKTHROUGH
VEXcode V5 Guide
Configuration, code, calibration β€” for projects from scratch (not import)
INTERACTIVE
Code Generator
Wizard that asks about your robot and produces a ready-to-paste main.cpp
PDF · PRINTABLE
Setup Guide (4 pages)
Print + hand to students — same content as this page
READY-TO-CALIBRATE
Clawbot 2822 SmartDrive (.v5cpp)
Open directly in VEXcode V5 (File β†’ Open Project). Skip paste step entirely. Working file with all fixes baked in — calibrate + run.
SINGLE-FILE · RECOMMENDED
Clawbot (single-file)
arm + claw · 345 lines · works in VEXcode V5 standalone
SINGLE-FILE · RECOMMENDED
Flex (single-file)
lift + claw · 293 lines · works in VEXcode V5 standalone
SINGLE-FILE · RECOMMENDED
Skimmer (single-file)
4 subsystems · 450 lines · works in VEXcode V5 standalone
MULTI-FILE · VS CODE EXT
Clawbot (multi-file)
Requires VEX VS Code Extension
MULTI-FILE · VS CODE EXT
Flex (multi-file)
Requires VEX VS Code Extension
MULTI-FILE · VS CODE EXT
Skimmer (multi-file)
Requires VEX VS Code Extension
SHELVED
PROS + EZ-Template
Previous toolchain — preserved for reference

This site is an informational reference. RECF EN4 prohibits AI-generated content in engineering notebooks and programming code. Rewrite everything in your own words.