Thread: c debugger
View Single Post
  #14   Spotlight this post!  
Unread 09-12-2004, 11:16
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,817
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: c debugger

Quote:
Originally Posted by stephenthe1
um, would this code cause two pistons to fire assuming they are hooked up to relay 1 and relay2. also, you'll notice in my if statements that I used if its 1, then to execute the stuff, is that the right way of asking if the switch is one, or should I do (p2_sw_trig01), I've seen that but didn't know what it meant. what's the correct way? thanks.

Code:
if (p1_sw_trig = 1) {
Needs to be:
Code:
if (p1_sw_trig == 1) {
And what Mike is referring to is that the check for p2_sw_trig will override any values you set after checking p1_sw_trig.

I assume you are looking for one button push to be forward and another to be reverse, and neutral if no button is pushed?

Just as an example, you could combine the checks on the neutral condition to make sure they don't override any other button push, e.g.,
Code:
if (p1_sw_trig == 0 && p2_sw_trig == 0) {
	 relay1_fwd = 0;
	 relay1_rev = 0;
	 relay2_fwd = 0;
	 relay2_rev = 0;
}
The p2 button will still override the p1 button if both are pushed at the same time.
Quote:
Originally Posted by stephenthe1
also, you'll notice in my if statements that I used if its 1, then to execute the stuff, is that the right way of asking if the switch is one, or should I do (p2_sw_trig01), I've seen that but didn't know what it meant. what's the correct way? thanks.
"if (p2_sw_trig01)" is treated the same as "if (p2_sw_trig01 == 1)"

[edit] Fixed my typo. (and I'm trying to be a good example). This is why you get other people to check your code. Thanks, Dave.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 09-12-2004 at 14:09.