|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
How do you program limit switches?
Right now I have a limit switch plugged into one of the ports on the Digital IO. Now what methods/classes do use to tell whether the limit switch is pressed or not. There doesn't seem to be a "limit switch" and I'm not sure what to use.
Anyone else know? |
|
#2
|
||||
|
||||
|
Re: How do you program limit switches?
Im working on the same thing for my team for tomorrow. What are you trying to control with the switch?
|
|
#3
|
|||
|
|||
|
Re: How do you program limit switches?
A motorized car jack that stops working when it goes too low or too high
|
|
#4
|
||||
|
||||
|
Re: How do you program limit switches?
DigitalInput name = new DigitalInput(slot)
fill in slot with the slot on the DIO that the switch is plugged into and name with whatever you want to call it. name.get() will return you the boolean indicating whether the switch is pressed or Unpressed. If it's wired right, true will be pressed and false will be unpressed |
|
#5
|
|||
|
|||
|
Re: How do you program limit switches?
Scissor jack? Very suave just to think of it.
|
|
#6
|
|||
|
|||
|
Re: How do you program limit switches?
Yup! We use it to change the angle of our shooter.
|
|
#7
|
||||
|
||||
|
Re: How do you program limit switches?
|
|
#8
|
|||
|
|||
|
Re: How do you program limit switches?
For some of you using command based programming, I noticed that the DigitalIOButton class wasn't working properly, so I programmed my own DigitalButton class using the very-functional DigitalInput class.
Code:
public class DigitalButton extends Button {
private int channel;
DigitalInput buttonInput;
public DigitalButton(int channel) {
this.channel = channel;
buttonInput = new DigitalInput(channel);
}
public int getChannel() {
return this.channel;
}
public boolean get() {
return buttonInput.get();
}
}
|
|
#9
|
|||
|
|||
|
Re: How do you program limit switches?
Thanks, guys! Limit switch is working
![]() |
|
#10
|
|||
|
|||
|
Re: How do you program limit switches?
Use a DigitalInput. It should be declared as a static variable, like this:
public static DigitalInput limitSwitch; Initialize it like this: limitSwitch = new DigitalInput(slot,channel); To use the limit switch, call the get() method on it, which, assuming you have it wired correctly, will return true if the switch is closed and false if it is open. Any more questions? |
|
#11
|
|||
|
|||
|
Re: How do you program limit switches?
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|