Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Micro Switch Code (http://www.chiefdelphi.com/forums/showthread.php?t=74295)

dboisvert 12-02-2009 21:25

Micro Switch Code
 
Declared 2 Micro Switches

Code:

DigitalInput *flipperdoorright;
DigitalInput *flipperdoorleft;

Where I want the variables to get data from

Code:

flipperdoorleft = new DigitalInput(1);
flipperdoorright = new DigitalInput(2);

What I want it do with those variables

Code:

                        if (m_leftStick->GetRawButton(5) == 1 && flipperdoorright == 1 ) {
                                flipperdoor->Set(Relay::kForward);
                                //delay(10);
                        } else if (m_leftStick->GetRawButton(4) == 1 && flipperdoorleft == 1 ){
                                flipperdoor->Set(Relay::kReverse);
                                //delay(10);
                        }
                        else{
                                flipperdoor->Set(Relay::kOff);
                        }


(The Error shows up on the if and else if lines)
Error: ISO C++ forbids comparison between pointer and integer

I only included the lines giving me the errors and those that are relative to the question.

So what am I doing wrong?

Alan Anderson 13-02-2009 00:15

Re: Micro Switch Code
 
The flipperdoorright variable is not the value of the switch. It's a pointer to the object which has methods for reading the switch.

Try flipperdoorright->Get() and flipperdoorleft->Get() instead.



Congratulations on a very good presentation of your problem, by the way.

dboisvert 13-02-2009 13:34

Re: Micro Switch Code
 
Thanks, I am actually just learning a lot of the C++ code this year but I think I am catching on pretty quick.

That solved my problem :)


All times are GMT -5. The time now is 02:41.

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