VEXcode V5 Setup Guide
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.
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
- VEXcode V5 installed — free from vexrobotics.com
- A single-file zip downloaded:
clawbot-vexcode-single.zip,flex-vexcode-single.zip, orskimmer-vexcode-single.zip - The zip contains one file:
main.cpp, plus a README - A text editor — Notepad, TextEdit, or any plain-text editor
- (Optional) A V5 brain for testing
STEP 1Create a fresh C++ project
- Open VEXcode V5
- File → New Text Project
- Choose C++ when prompted
- Use the Empty Project template (NOT "Clawbot Drivetrain" or any template that pre-configures devices)
- File → Save As, give it a name (e.g.,
Clawbot-2822)
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).
- Open the Devices panel (left sidebar)
- Click Add a Device for each device needed by your reference project
- Use the exact device names listed in the reference's pragma region (top of
main.cpp)
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
- In VEXcode, click into the
main.cppfile - Select all (Ctrl+A / Cmd+A)
- Delete (so the file is empty)
- Switch back to the reference
main.cppin your text editor - Select all → copy (Ctrl+C / Cmd+C)
- Switch to VEXcode → paste → save (Ctrl+S / Cmd+S)
#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
| Error | Fix |
|---|---|
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
- Connect V5 brain via USB cable (or controller-to-brain VEXnet)
- Brain icon at the top of VEXcode turns green
- Pick a slot from the dropdown (default: slot 1)
- Click Download (arrow icon)
- Press Run on the brain to start
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.
| Section | Contents |
|---|---|
| 1. HARDWARE | Motor / sensor / pneumatic definitions (was robot-config.cpp) — edit ports here |
| 2. FORWARD DECLS | Function signatures so code can call functions defined later in the file |
| 3+. SUBSYSTEMS | One section per mechanism — arm, claw, lift, intake, tube, pneumatics. Tunable constants at top, then init / control / auton API functions |
| AUTONS | Drive helpers + per-auton routines |
| AUTON SELECTOR | Brain-screen selector (~30 lines — VEXcode doesn't ship one) |
| MAIN | pre_auton(), autonomous(), usercontrol(), main() — pure orchestration |
TUNINGWhat to edit after a successful build
- 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. - 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. - Autons. The
drive_for_ms(power, ms)helper needs calibration for your wheel size and gearing. Run auton_drive_test and measure actual distance. - 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
| Aspect | PROS + EZ-Template (painful) | VEX VS Code Extension (simple) |
|---|---|---|
| Install | VS Code + PROS CLI + library imports + makefile config | VS Code + one click for the VEX extension |
| Terminal commands? | Yes — pros, make, library management | None |
| New project flow | CLI command + template + manual files | Sidebar → New Project → V5 → C++ |
| Build / Download | Terminal or tiny grey icon | Big buttons in the sidebar |
| Devices panel | None | Built-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
- Install VS Code (from code.visualstudio.com)
- In VS Code: install the VEX Robotics extension (Ctrl+Shift+X, search "VEX")
- New Project → V5 → C++ → Empty Project
- Download the multi-file reference (
<robot>-vexcode-project.zip) instead of single-file - Copy
src/*.cpp+include/*.hinto the matching folders - 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.