View Single Post
  #3   Spotlight this post!  
Unread 01-02-2008, 11:07
timville's Avatar
timville timville is offline
Registered User
AKA: Timothy Friez
FRC #1185 (X-Bots)
Team Role: Alumni
 
Join Date: Mar 2007
Rookie Year: 2003
Location: Pittsburgh
Posts: 18
timville is an unknown quantity at this point
Send a message via AIM to timville
Re: Hybrid Mode Help

Hi ShotgunNinja

If you wanted to interface with the Hybrid Mode with the IR, we actually have a sample to do. Here's the code for the Initialization and Autonomous Sections:

Code:
#include "FRC_Comp_Include.c"

void Initialization()
{
	bMotorReflected[port2] = true;  //Reflect Motor
	frcDigitalIODirection[pio3] = dirInput;  //IR Output 1 on Digital IO 3
	frcDigitalIODirection[pio4] = dirInput;  //IR Output 2 on Digital IO 4
	frcDigitalIODirection[pio5] = dirInput;  //IR Output 3 on Digital IO 5
	frcDigitalIODirection[pio6] = dirInput;  //IR Output 4 on Digital IO 6
}

task Autonomous()
{
	int IRswitch1;
	int IRswitch2;
	int IRswitch3;
	int IRswitch4;

	while(true)
	{
	   IRswitch1 = frcDigitalIOValue[pio3];  //Update Variables
	   IRswitch2 = frcDigitalIOValue[pio4];  //So we can see status in the Debugger
	   IRswitch3 = frcDigitalIOValue[pio5];
	   IRswitch4 = frcDigitalIOValue[pio6];

	   if(IRswitch1 == 1)  //If Switch 1 is pressed (it pulses, doesn't remain on)
	   {
	     motor[port1] = 50;
	     motor[port2] = 50;
	   }

	   if(IRswitch2 == 1)  //If Switch 2 is pressed
	   {
	     motor[port1] = 0;
	     motor[port2] = 0;
	   }

	   if(IRswitch3 == 1)  //If Switch 3 is pressed
	   {
	     motor[port1] = -50;
	     motor[port2] = 50;
	   }

	   if(IRswitch4 == 1)  //If Switch 4 is pressed
	   {
	     motor[port1] = 50;
	     motor[port2] = -50;
	   }
	}
}
Yes, You can use Typedef structs like ANSI C.

What issues are you having with the compiler?

I recommend you take a look at some of the support/samples we have at the ROBOTC website: http://robotc.net/ifi/frc/support.htm
__________________
2003 - Rookie All-Stars Awards - #1185 (Pittsburgh)
2004-2008 FIRST Volunteer - Ref/Head Ref (Pittsburgh)
2002-2007 FIRST Lego League Volunteer - Head Ref (Pittsburgh)