View Single Post
  #4   Spotlight this post!  
Unread 14-02-2006, 21:46
DanDon's Avatar
DanDon DanDon is offline
ohhh MY god
AKA: Dan Hoizner
FRC #0375 (The Robotic Plague)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Staten Island, NY
Posts: 1,432
DanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond repute
Send a message via ICQ to DanDon Send a message via AIM to DanDon Send a message via MSN to DanDon
Re: A few simple programming questions;

Code:
  if(p3_sw_top == 1)
   { 
   pwm09 = 127;
   pwm10 = 127;
   }
   else
   {
   pwm09 = 254;
   pwm10 = 254;
   }
This might be your intention, but with this code, the pwm's will only be at 127 when the button is held down, when the button is not held down, they will be at 254.


Quote:
2. We are using spikes this year, and I am not sure how to program them, I'm sure I have to program it somehow but I am at a lost of how to.
With spikes, you would basically program them using two variables. If your spike was hooked up to relay1, then your two variables would be:
relay1_fwd and relay1_rev. If you wanted to fire the spike in one direction, you would set:

Code:
relay1_fwd=1;
relay1_rev=0;
The other direction would be:

Quote:
relay1_fwd=0;
relay1_rev=1;
And neutral would be:
Code:
relay1_fwd = relay1_rev = 0;
Quote:
else (p3_sw_trig == 0);
{
pwm09 = 254;
pwm10 = 254;
}
If you were to have the condition after the else, despite the fact that it's not needed, since the button can only be at 1 or 0, and if it isn't at 1, then a value of 0 is implied, the statement would have to be an

Code:
else if(p3_sw_trig==0)
You also should not have a semi-colon right after an if or else statement.

Quote:
think you only need one = when referring to the value of the button, not ==.
This is not true. The '==' operator is the equality operator in C, '=' is the assignment operator, which would set the variable equal to what you are comparing it with, and the condition would always be true.

Regarding the syntax error, from a brief glance at the code, it looks like you might be missing a brace or two. Try adding them one by one to the end of your code, and see if that helps.

Hope this helps,
__________________