PROS Example Project

Would anyone be willing to post an example project of how to set up a pros project? I’ve scoured the forums and github and I haven’t found anything useful in terms of setting up a simple project. This is mainly for reference, I just want to see how you would set up motors and methods in a header file so you can call and access those in any source files you create.

I’ve been struggling to get working code on my chassis because I have an entangled mess with all my files and it would be very helpful to base my project off of something simple.

P.S. I’ve had my project reviewed by various people and their explanations haven’t been helpful, I’m more of a visual learner.

add config.hpp in include folder and add following line to i src/initialize.cpp

#include “main.h”
#include “config.hpp”

pros::Controller master (pros::E_CONTROLLER_MASTER);
pros::Controller partner (pros::E_CONTROLLER_PARTNER);
pros::Motor leftfront (6, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor leftback (7, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor rightfront (9, pros::E_MOTOR_GEARSET_18, true, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor rightback (10, pros::E_MOTOR_GEARSET_18, true, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor lift (20, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor claw (14, pros::E_MOTOR_GEARSET_18, true, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor ballintake (19, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_COUNTS);
pros::Motor catapult (13, pros::E_MOTOR_GEARSET_36, false, pros::E_MOTOR_ENCODER_COUNTS);
pros::ADIDigitalIn limitswitch (1);
pros::ADIAnalogIn potentiameter (2);
pros::ADIGyro gyro (3);
pros::ADIDigitalIn limitswitchball(4);


#ifndef CONFIG_H
#define CONFIG_H

extern pros::Motor leftfront ;
extern pros::Motor leftback ;
extern pros::Motor rightfront ;
extern pros::Motor rightback ;
extern pros::Motor lift ;
extern pros::Motor claw ;
extern pros::Motor ballintake ;
extern pros::Motor catapult ;
extern pros::Motor flipper ;
extern pros::Controller master; // master control
extern pros::Controller partner; //partner control
extern pros::ADIAnalogIn bumper; // not use yet
extern pros::ADIAnalogIn potentiameter; //potentiameter for claw
extern pros::ADIGyro gyro;
extern pros::ADIDigitalIn limitswitch ; //limitswitch for arm lift
extern pros::ADIDigitalIn limitswitchball ; //limitswitch for ball shoot


Would this give you access to call motors and methods in all other files just by #include “main.h”? (Since main.h and initialize are linked together)

you will need to #include “config.hpp” in all other files.

If you want to draw to the screen and learn how to use LVGL here is a tutorial.

I still get an error when I do that.

This code I have to is all on this repository on GitHub. I’m still getting an error when I call the motor in the autonomous.cpp file even though I included it.

I think my computer may be glitching out or something because now it recognizes the motor exists. I’m not 100% sure it will work since I haven’t uploaded it to the brain. Hopefully it does. Regardless, it would be nice if someone could review it.

You never include anything in that code. You also have no code in autonomous.cpp. Maybe you have not pushed recently?

I’ve been working on an example project it’s still a WIP but here it is hope it helps.


I’ve updated the repository, for some reason it didn’t update the files when I uploaded them. Anyways, will putting method headers in the config.hpp of methods created in source files (.cpp) allow me to access those methods by #include the header file in other source files? (wording of question is a bit confusing)

the autonomous has a motor moving for an indefinite amount of time. Again, the purpose of this project is sort of a proof of concept as I’m switching from VCS, I just need to understand how linking files works with this IDE and pros API.

you should keep
#ifndef CONFIG_H


#pragma once does the same thing, no?

When I downloaded the program on the v5 brain, nothing happens, as in, no motors move. And I get a JSON error but it doesn’t indicate what’s causing that.16%20AM

We’ve gotten a couple reports from various folks using macOS. We haven’t been able to reproduce the issue and are looking for someone to help us do some troubleshooting on our Slack or on GitHub. If you could join and help us do some diagnosis so we can fix the issue, that would be appreciated.

I’m on my phone right now - I will share the Slack invitation/GH issues when I get home if someone doesn’t beat me to it.

1 Like

Here it is =)
Do you need an invitation?

1 Like

#pragma once does the same thing, no?

Yes. It should.

Yeah I’d be willing to, what I am supposed to do to assist?

This is the issue tracking what you’re experiencing - it has some instructions there.