Go to Post When in doubt, ask... don't assume (unless you don't mind wasting time/money). - Bill Gold [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #15   Spotlight this post!  
Unread 09-12-2004, 11:16
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
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,862
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.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Debugger and Simulation in new IDE? authgeek1218 Programming 1 08-12-2003 18:39


All times are GMT -5. The time now is 14:07.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi