|
Re: Photo Switch!
It is a programming problem we have. So what we are trying to do is when there is light we want it to activate our solenoid and when it is dark we want it to close our solenoid. Our solenoid isn't spring resettable this year so here is what i have so far.
================================================== ==========
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.Solenoid;
public class test extends IterativeRobot {
DigitalInput lightsensor = new DigitalInput(2);
Solenoid solenoid5 = new Solenoid(5);
Solenoid solenoid6 = new Solenoid(6);
public void teleopInit() {
solenoid5.set(true)
solenoid6.set(false)
}
public void teleopPeriodic() {
if(lightsensor.getAnalogTriggerForRouting() == false) {
solenoid5.set(false);
solenoid6.set(true);
}else{
solenoid5.set(true);
solenoid6.set(false);
}
}
================================================== ==========
So part of this code works, When the sensor is tripped it reads dark and solenoid 5 is set false and 6 is set true, but when it sees light again it doesnt reset.
|