Coding in V5? C++ vs. ROBOTC

  1. 6 days ago

    csiv23

    May 14 Hopkinton, MA, 01748 2602J

    Hey, I was researching into V5 and I noticed that it is now being programmed through "Vex C++". How would you write lines of code through this language as compared to ROBOT C? For example, in ROBOT C, I would write

    motor[Claw] = 127;
    wait1Msec(1000);

    How would I write this in Vex C++? Additionally, what are the main differences between ROBOT C and Vex C++? Thanks in advance.
    "

    I don't know the specifics for the function calls and objects, but you'll see commands that look something like this:

    motorClaw.setPower(127);

    in place of

    motor[Claw]=127;

    What I recommend is looking up a quick tutorial in C++. Once you understand the idea behind object-oriented programming, with the similarities between C and C++, you'll pick up the rest quickly. The trick is really just understanding how objects are implemented and used, and you'll get that from all sorts of online tutorials.

  2. Purple Knight

    May 14 Gallifrey

    I don't know the answers to most of your questions, but I do know that C++ is based on C, so that whatever lines you desire to write will be relatively similar in both languages.

  3. callen

    May 14 Answer Braintree, MA, USA

    I don't know the specifics for the function calls and objects, but you'll see commands that look something like this:

    motorClaw.setPower(127);

    in place of

    motor[Claw]=127;

    What I recommend is looking up a quick tutorial in C++. Once you understand the idea behind object-oriented programming, with the similarities between C and C++, you'll pick up the rest quickly. The trick is really just understanding how objects are implemented and used, and you'll get that from all sorts of online tutorials.

  4. 5 days ago

    csiv23

    May 15 Hopkinton, MA, 01748 2602J

    Thanks! Do you know how timers work, as in ROBOTC's wait1Msec(x) command?

  5. callen

    May 15 Braintree, MA, USA

    The standard C command for this is

    void delay(unsigned int);

    So you use it like this to delay 500 ms:

    delay(500);

    This is essentially the same as wait1Msec(500); that you would use in RobotC. What I prefer is it is consistent throughout C. So, for example, if you program Arduinos using C/C++, you would use the same command.

 

or Sign Up to reply!