Thread: [FTC]: Robot C
View Single Post
  #8   Spotlight this post!  
Unread 06-11-2009, 12:52
grampashades grampashades is offline
Registered User
FTC #0121
 
Join Date: Jan 2007
Rookie Year: 2004
Location: URI
Posts: 4
grampashades will become famous soon enough
Re: [FTC]: Robot C

Quote:
Originally Posted by jamie_1930 View Post
From what we've been doing the condition for your if statements should look like this

if(joy1Btn(1) == 1)
{
code here
}

this will make it so execute code when button 1 on joystick 1 is pressed.
First you guys want:

motor[motorE] = joystick.joy1_y2;

With C programming you set the thing on the left to the value on the right. The other way around shouldn't work. *Unless Robot C built it into the compiler to accept it both ways.

Also as a note to save you guys a lot of frustration later. I would suggets you put in a "dead zone" that stops you from powering the motors with too little voltage.


if ( ( joystick.joy1_y2 < -10) || ( joystick.joy1_y2 > 10))
{
motor[motorE] = joystick.joy1_y2;
}
else
{
motor[motorE] = 0;
}

your motors will thank you.

Second I've found throughout my tetsing that it is much better to program the buttons as such:


if(joy1Btn(1) )
{
code for what you want to happen here
}
else
{
code to make that stop happening
}

While there is not techinical difference in this case....for whatever reason the software gods seem to prefer it without the "==1"

finally, while techinically yes...you could put autonomous code into the "code here" section but you could also run into some serious problems...unless you keep all of your logic sound. You can easliy start getting in trouble when you try things like this.
Reply With Quote