You know the basics. Now let's close the gaps that trip up every new text coder — errors, debugging, and writing code that doesn't break.
When you run pros build, errors look like this in the terminal:
Every error has three parts: file name, line number, and description. Always start by clicking to line 14 — the fix is almost always right there.
You forgot a semicolon at the end of a line.
You opened a curly brace { but never closed it with }. Count your braces — they must match.
You're using a variable or object name that doesn't exist — usually a typo or you forgot to declare it in robot-config.cpp.
The function expects a certain number of values inside ( ) and you gave it the wrong count.
Not a crash — just a heads-up. You created a variable but never used it. Either use it or delete it.
Don't panic! Usually one small mistake (a missing { or ; early in the file) causes a cascade of fake errors below it.
printf() to send those messages and pros terminal to receive them. It's how you see what's actually happening inside your code.You'll see your messages scrolling in real time as the robot runs. When you're done debugging, press Ctrl+C to stop.
Not sure which line is causing a problem? Temporarily disable lines by turning them into comments with Ctrl+/:
Re-enable lines one at a time until the bug reappears — that's your culprit.
You can also print to the V5 Brain's screen — useful at competitions when you can't plug in a laptop:
printf("CODE STARTED\n"); at the very beginning of autonomous. If you open the terminal and don't see it, your code never ran — which tells you it's a hardware/upload problem, not a code problem.pid_wait() is the #1 autonomous mistake. Without it, the robot starts the next movement immediately — before the first one finishes — and everything goes wrong.In C++, you must declare (create) a variable before you use it. The compiler reads top to bottom, so if you try to use something it hasn't seen yet, it will error:
pros build converts your text into machine code the V5 Brain can actually execute.pros upload sends the compiled binary to the Brain over USB. Then your robot runs it.Everything inside { } should be indented one level (2 or 4 spaces, or one Tab). VS Code does this automatically when you press Enter after a {.
Use camelCase for variable names: first word lowercase, each new word capitalized. armTargetPosition, intakeRunning, pneumaticExtended.
Don't cram everything into opcontrol(). Break it into helper functions — one per mechanism:
src/main.cpp unless told otherwise.Find and fix all the errors in this code block (there are 4):
In your opcontrol() loop, add a printf that prints the left joystick's Y-axis value every 100ms. Then open pros terminal and move the stick to see it change.
Create a function called score_game_element() that: spins the intake for 600ms, stops it, drives forward 6 inches, then stops. Call it from autonomous.
Use Shift+Alt+F to auto-format, then manually improve the variable names:
undefined reference to ‘armControl’. This is most likely a:Ready for real robot code? The next step is writing a full competition program with drive, arm, intake, and autonomous.