Thread: Photo Switch!
View Single Post
  #3   Spotlight this post!  
Unread 17-02-2013, 21:43
tuXguy15's Avatar
tuXguy15 tuXguy15 is offline
Team Mentor
AKA: Devin Kolarac
FRC #2559 (Normality Zero)
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Harrisburg, PA
Posts: 127
tuXguy15 is an unknown quantity at this point
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.
Reply With Quote