I have to IR Board wired up to digital ins 1-4. I understand that I am supposed to use those inputs in the code, but I have tried alot of things and it seems like everytime it just doesnt do as I intend. I have seen some of the sample code posted here before, but it was in the user_routines.c and not user_routines_fast.c as I would expect. Can anyone help me please?
I got it to work with easyC
Prior to the start of the hybrid period, the robot is disabled
and is running through the packet handling loop that is normally
used for the operator controlled period. During this time you
might receive the IR commands and set a state variable
to the values 1, 2, 3, or 4, based on the last command seen.
During the hybrid period, the robot will be controlled by the
“autonomous” packet loop, and you might execute one of four
plays based on the value of this state variable. The total number
of plays might be greater, selected by other switches on the robot
that are set when the robot is set in its starting position, but you
can only select one of four plays with the IR commander after
the balls are placed and these plays must be posted.
An alternative approach is to establish some limited remote control
of the robot using four available actions, coded entirely in the autonomous
code, subject to the applicable rules.
Amicsa,
What exactly are you trying to do?
A couple of things:
Whatever you plug the IR board into must be configured as an INPUT; otherwise it will always read 0.
If the IR board is not plugged in, you’ll get all 1s for the inputs, so you need to check for that as well.
If you want it to do something in hybrid mode, it does need to go in the user_routines_fast.c file, in the user_autonomous method (or else it’s called something similar to that - I’m using WPILIB and so don’t remember exactly).
Depending on what you do with them, you’ll want to write code for each input.
if(rc_dig_in01){
[INDENT]do_stuff_01();
}//end if
else if(rc_dig_in02){
[INDENT]do_stuff_02();
}//end if
else if(rc_dig_in03){
[INDENT]do_stuff_03();
}//end if
else if(rc_dig_in04){
[INDENT]do_stuff_04();
}//end if
[/INDENT]