Controlling motor with controller

Hi all, I’ve coded before, but never in VEX. I want a motor to move when I depress a button on my controller. The specific part of my program that does this is:

if controller_1.buttonr2():
    sucker_1.spin(FORWARD)
pass

When the program is ran, I get the error:
“Traceback (most recent call last): Python exception …
File “userpy”, line 90, in
AttributeError: no such attribute”

Do I need to import some sort of controller library for this function to work correctly?
Any help is appreciated, thank you in advance.

I would’nt suggest using python for coding your robot. If you able to use C++ its much easier to learn in my opinion. You should not have to install anything.

What programming software are you using?

Hes most likely using the vexCode software that has text and blocks in it, it allows python and not C++ for some reason

If that’s the case I’m of no use. Good luck!

Please post your complete program, that will make the debugging process go a lot faster.

2 Likes

Yea, I would like to use C++, but the option is grayed out for some reason.

------------------------------------------

Project: VEXcode Project

Author: VEX

Created:

Description: VEXcode V5 Python Project

------------------------------------------

Library imports

from vex import *

Begin project code

while 0 == 0:
if controller_1.buttonr2.pressing():
sucker_1.spin(FORWARD)
pass
pass

if you want to use c++ to code, you need to download vexcode v5 pro.
vexcode v5 only has blocks and python.

rant

Chaging the names of these programs was a bad move, it causes so much confusion about which program to download. vexcode v5 and vexcode v5 pro describe nothing about what the program is for, while the old names, vexcode v5 blocks (you could add “& python” to the end to be even more descriptive) and vexcode v5 text describe the programs and their uses perfectly. even clicking “learn more about this version” on the website tells you very little about what each one does. Just my 2 cents.

6 Likes

Whitespace and case both matter in Python, the main part of your program should be:

# Begin project code
while True:
    if controller_1.buttonR2.pressing():
        sucker_1.spin(FORWARD)

AttributeError: no such attribute is the kind of error you’d expect to get when you refer to an attribute that doesn’t exist, such as buttonr2 (which is not the same as buttonR2).

3 Likes

That’s not a rant. Not enough whiteboxes, right Matt?

5 Likes

You should use VEXcode Pro V5 - v2.0.1 that you can download from this link.

Once C++ is implemented in VEXcode V5, the old naming convention would make no sense because you’d have “VEXcode V5 Blocks, Python and C++” as one piece of software, and “VEXcode V5 C++” as the other.
Whilst you could debate what the names should be, VEXcode V5 and VEXcode V5 Pro do suggest that one version is for more experienced users.

It’s pretty well explained here, but perhaps could be a little clearer:
https://www.vexrobotics.com/vexcode

3 Likes

if they plan on implementing c++ into vexcode v5, why even have 2 different programs at that point? idk, I’ve just seen so much confusion caused by people not knowing which program to download.

My guess is because C++ will never be integrated into VEXcode in the same way that it is using the Monaco editor in Pro where you have a lot more control over all sorts.
It’ll be beginner C++ and higher (Pro if you will) C++

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.