|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
define irswitch?
how do you define the ir board commands in the program.
this is what we have but we don't know if it is right #define IRswitch1 #define IRswitch2 #define IRswitch3 #define IRswitch4 or can someone post how they defined the IRswitch? |
|
#2
|
||||
|
||||
|
Re: define irswitch?
You need to use #define to assign a value to the IRswtich things. They are only placeholders, the compiler will go through and replace all "IRswitch1" with whatever you put after it. So it would like:
Code:
#define IRswitch1 rc_dig_in01 #define IRswitch2 rc_dig_in02 #define IRswitch3 rc_dig_in03 #define IRswitch4 rc_dig_in04 Code:
if (!IRswitch1) //If the IR has been pressed auto_routine_1(); //Do whatever when switch is down } Code:
// IR Inputs #define IR_DIG_1 rc_dig_in07 #define IR_DIG_2 rc_dig_in08 #define IR_DIG_3 rc_dig_in09 #define IR_DIG_4 rc_dig_in10 // IR Values #define IR_DISCONNECTED (IR_DIG_1 && IR_DIG_2 && IR_DIG_3 && IR_DIG_4) #define IR_1 (IR_DIG_1 && !IR_DISCONNECTED) #define IR_2 (IR_DIG_2 && !IR_DISCONNECTED) #define IR_3 (IR_DIG_3 && !IR_DISCONNECTED) #define IR_4 (IR_DIG_4 && !IR_DISCONNECTED) |
|
#3
|
||||
|
||||
|
Re: define irswitch?
We NOT our digital ins right there at the macro. Like what psy_wombats said, but I think that it reads better in the if statements. Digital inputs become false when the circuit is closed. =)
Code:
#define IRswitch1 !rc_dig_in01 |
|
#4
|
|||||
|
|||||
|
Re: define irswitch?
That's correct for switches or "open-collector output" sensors that complete a connection to ground. But the IR sensor is not that kind of circuit. It provides a logic level output, with the digital input resting at zero and going to one when the signal is recognized.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Define Happiness | Elgin Clock | Chit-Chat | 17 | 30-04-2007 21:59 |
| Define A Wedge | T3_1565 | Rules/Strategy | 18 | 11-01-2007 21:22 |
| Define FIRST | slickguy2007 | General Forum | 24 | 13-10-2006 08:24 |
| #define creation | NASAbound1636 | Programming | 3 | 02-02-2006 23:40 |
| Conditional #define Statements | Ian W. | Programming | 3 | 14-02-2004 18:14 |