View unanswered posts | View active topics It is currently Sat Oct 21, 2017 10:10 am






Reply to topic  [ 5 posts ] 
Program only giving power to one motor 
Author Message
Rookie

Joined: Tue Feb 23, 2016 6:01 pm
Posts: 2
Post Program only giving power to one motor
So I learned how to use robotc just recently, programmed my tank drive, it worked. Then I made a pinball hammer for the nothing but net game. I wanted to program it to the right shoulder buttons, being an fps gamer, and being used to that, on the main controller. As soon as I did so, the program would only ever give power to the left front motor on the drive train. Can sombody help me fix this, and tell me why this happens? my program:

Code:
#pragma config(Motor,  port2,           RightRearDrive, tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port3,           RightFrontDrive, tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port4,           PinballShooter, tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port8,           LeftFrontDrive, tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port9,           LeftRearDrive, tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
            while(true)
   // tank drive with left side ch 3 and right side ch 2
   motor[LeftFrontDrive] = vexRT[Ch3];
   motor[LeftRearDrive] = vexRT[Ch3];
   motor[RightFrontDrive] = vexRT[Ch2];
   motor[RightRearDrive] = vexRT[Ch2];
         while(true)

   if(vexRT[Btn6D] == 1)
   {
   //pull back pinball shooter
   motor[PinballShooter] = 127;
   }
         while(true)
   if(vexRT[Btn6U] == 1)
   {
   //reverse pinball shooter
   motor[PinballShooter] = -127;
   }
}


Tue Feb 23, 2016 6:13 pm
Profile
Expert

Joined: Thu Dec 01, 2011 12:07 am
Posts: 151
Post Re: Program only giving power to one motor
A while statement will do one of the following:
1) Run all lines within braces{} immediately following the while
or
2) Run the next line of code

You should add braces {} after the while statements just like the if statements.


Wed Feb 24, 2016 6:33 pm
Profile
Rookie

Joined: Tue Feb 23, 2016 6:01 pm
Posts: 2
Post Re: Program only giving power to one motor
Ahh the drive train works now, thank you.
Having a bit of trouble with getting the program to give power to the pinball motor though


Thu Feb 25, 2016 6:18 pm
Profile
Expert

Joined: Thu Dec 01, 2011 12:07 am
Posts: 151
Post Re: Program only giving power to one motor
Post your code so we can see how your while loops are structured.


Sat Feb 27, 2016 7:52 pm
Profile
Rookie

Joined: Thu Jun 09, 2016 1:39 am
Posts: 5
Post Re: Program only giving power to one motor
If you say while(true) it will run forever. You can only have one while(true) loop because you will never leave it. So this will only run the first set of statements. If you adjust it so all the code is inside the first while(true) loop it should work.


Thu Oct 12, 2017 9:28 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.