The robot is to move via remote, in tank mode.has an arm that goes up and down (one motor)has a claw that closes (one motor) 4 motors total. I want to run the arm and the claw off the channel 5 and 6 buttons on the back of the controller. I have posted my program, why is it not working, and what can I do to fix it?please help we have a competition on thursday!

Looking at the posted code, when exactly will the while loop's condition become false (or, when will 1 not equal 1?) and the rest of the code execute? Any time you have an opening bracket on a conditional statement, you will need a closing bracket to 'encompass' all of the code you wish to execute within that statement.

Looking at the posted code, when exactly will the while loop's condition become false (or, when will 1 not equal 1?) and the rest of the code execute? Any time you have an opening bracket on a conditional statement, you will need a closing bracket to 'encompass' all of the code you wish to execute within that statement.

when i run the debug for the code, it gets stuck in that loop, with the controller sticks since i added that bracket. and when it is not connected the motors do not move, do i need to put in something with speeds at certain conditions? its been 4 years since I did any of this from scratch. we have this competition this wednesday. so I have tonight and tomorrow night to get this code to work, also we maybe adding another motor and make the arm a double hinge. and help you could give me would be amazing, and I really do appriecate this

Leigh

Mon Mar 04, 2013 5:16 pm

JohnWatson

Site Admin

Joined: Thu May 24, 2012 12:15 pmPosts: 722

Re: Programming beginner needs major help!

You may want to look through the Video Curriculum Trainer for the VEX Cortex. Specifically, you will want to look through the 'Remote Control' sections that explains the code that specifically pertains to remote control operation.

For this specific code example, the while loop is still the problem. Remember, a loop will continue running the code that is 'contained' inside of its opening and closing brace set {} while its condition is true:

Code:

while (1 == 1) //The code in between the next set of { and } will run while 1 is equal to 1{ //Opening brace for the while loop

//Any code placed in here, between the opening and closing brace, will run while 1 is equal to 1. Since 1 will always equal 1, this code will run indefinitely; the loop will never 'exit' to the other portions of code

} //Closing brace for the while loop

//Any code placed outside of the while loop will not reach since 1 will always equal 1; the condition never becomes false, and the code never stops looping.

If you wish to run the entire program continually, you will need to place all of the code inside of the while loop's {} braces. This will make sure that each command is executed upon each pass through the loop.

ok I understand that much now. When I run the debugger, the robot now constantly runs the arm and claw motors. and when it is unplkugged it does not respond to my controller. this is so frustrating!

JohnWatson wrote:

You may want to look through the Video Curriculum Trainer for the VEX Cortex. Specifically, you will want to look through the 'Remote Control' sections that explains the code that specifically pertains to remote control operation.

For this specific code example, the while loop is still the problem. Remember, a loop will continue running the code that is 'contained' inside of its opening and closing brace set {} while its condition is true:

Code:

while (1 == 1) //The code in between the next set of { and } will run while 1 is equal to 1{ //Opening brace for the while loop

//Any code placed in here, between the opening and closing brace, will run while 1 is equal to 1. Since 1 will always equal 1, this code will run indefinitely; the loop will never 'exit' to the other portions of code

} //Closing brace for the while loop

//Any code placed outside of the while loop will not reach since 1 will always equal 1; the condition never becomes false, and the code never stops looping.

If you wish to run the entire program continually, you will need to place all of the code inside of the while loop's {} braces. This will make sure that each command is executed upon each pass through the loop.

Mon Mar 04, 2013 6:06 pm

darkxkitten

Rookie

Joined: Mon Mar 04, 2013 10:52 amPosts: 8

Re: Programming beginner needs major help!

ok robot runs successfully. I followed the instructions for the buttons to run my arm and claw. exactly as they said the arm and claw should move. BUT they do not move correctly. I have ports 6 and 7 for the motors, and channels 5 and 6. the code should work, I followed the tutorial perfectly... please help

JohnWatson wrote:

You may want to look through the Video Curriculum Trainer for the VEX Cortex. Specifically, you will want to look through the 'Remote Control' sections that explains the code that specifically pertains to remote control operation.

For this specific code example, the while loop is still the problem. Remember, a loop will continue running the code that is 'contained' inside of its opening and closing brace set {} while its condition is true:

Code:

while (1 == 1) //The code in between the next set of { and } will run while 1 is equal to 1{ //Opening brace for the while loop

//Any code placed in here, between the opening and closing brace, will run while 1 is equal to 1. Since 1 will always equal 1, this code will run indefinitely; the loop will never 'exit' to the other portions of code

} //Closing brace for the while loop

//Any code placed outside of the while loop will not reach since 1 will always equal 1; the condition never becomes false, and the code never stops looping.

If you wish to run the entire program continually, you will need to place all of the code inside of the while loop's {} braces. This will make sure that each command is executed upon each pass through the loop.

Mon Mar 04, 2013 9:04 pm

JohnWatson

Site Admin

Joined: Thu May 24, 2012 12:15 pmPosts: 722

Re: Programming beginner needs major help!

Please try to keep the conversation to one thread, as splitting it across multiple threads will generally only create confusion. From the code posted on this side thread, the code looks correct as far as I can see; there may be a wiring issue or joystick connection issue. I highly suggest going through all of the Curriculum Video Trainer sections, as they walk through the entire coding process step-by-step and will help you immensely in the programming process.

Who is online

Users browsing this forum: No registered users and 2 guests

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