View unanswered posts | View active topics It is currently Fri Sep 21, 2018 9:31 pm






Reply to topic  [ 3 posts ] 
Custom code not working with joystick 
Author Message
Rookie

Joined: Wed Nov 18, 2015 6:02 pm
Posts: 4
Post Custom code not working with joystick
My group and I have been attempting to solve this issue for a while now, and I finally bit the bullet and made an account here.

Here is our code (not all of it, just an example):

Code:
task main() {
    while (1 == 1) {
        if (vexRT[Btn8U] == 1) {
            motor[port2] = 63;
            ...
        }
    }
}


Now, without the if statement, the code works and can be run from the computer. However, we want to make this code work when the cortex is not connected to the computer, as the code makes the robot move through an obstacle course. We know we can just eliminate the if statement and turn the robot on at the start of the obstacle course, but we would prefer to start the code whenever we click the button (not least for practice with RobotC). This isn't so much about making the robot move through the obstacle course as it is about making the robot move when the button is pressed.

The cortex and joystick have been updated numerous times to 4.25, the cortex and joystick are power-cycled each time the code is re-downloaded, and both the computer and cortex are set to USB-only communication. The cortex and joystick both have enough battery power. When we press the button after everything is turned on, nothing happens. What are we doing wrong here?


Wed Nov 18, 2015 6:28 pm
Profile
Moderator
Moderator

Joined: Tue May 19, 2015 3:07 pm
Posts: 91
Post Re: Custom code not working with joystick
Okay so if they are set to USB only communication than they won't connect over Vexnet. That means that your joystick is not connected and your button press wouldn't be sent to the robot.

What do the lights look like on the joystick and the cortex?


Fri Nov 20, 2015 2:46 pm
Profile
Rookie

Joined: Wed Nov 18, 2015 6:02 pm
Posts: 4
Post Re: Custom code not working with joystick
We connected the controller with a USB cable, and the two were connected according to the lights on the joystick and the microcontroller.

The problem was fixed when we switched over to the competition template and put this code into the "usercontrol" task. What I don't understand is why it didn't work with just the normal default task ("main")?


Sat Nov 21, 2015 7:36 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.