View Single Post
  #3   Spotlight this post!  
Unread 18-02-2012, 00:23
NS_Radication's Avatar
NS_Radication NS_Radication is offline
Student
AKA: Marco Schoener
FRC #1369 (Minotaur)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2009
Location: Tampa
Posts: 88
NS_Radication is an unknown quantity at this point
Re: Help Please!(Rookie Team)

Quote:
Originally Posted by Ginto8 View Post
I don't really know the electrical side of things here, but I do know that there's a pretty simple method for using Spike relays: the Relay class.
Basically, you initialize one with the required port and the direction:
Code:
Relay relay = new Relay(PORT,direction); // direction can be Relay.Direction.kFoward,Relay.Direction.kReverse, or Relay.Direction.kBoth
Then you set it to one of four options (but it will throw an InvalidValueException if you set it to a direction it isn't configured for):
Code:
relay.set(Relay.Value.kOff); // 0v-0v, any direction
relay.set(Relay.Value.kForward); // 12v-0v, kForward or kBoth
relay.set(Relay.Value.kReverse); // 0v-12v, kReverse or kBoth
relay.set(Relay.Value.kOn); // 12v-12v, any direction
Correction:

relay.set(Relay.Value.kForward or kReverse)

Should be

relay.setDirection(Relay.Direction.kForward or kReverse, or kBoth);

Hope this helps! Happy Competitions!
__________________
Team 1369
Senior
Head Programmer (Java)
Head Electrician
Reply With Quote