![]() |
Photo Switch!
Hello, this is team 2559 and we are trying to set up a photo switch that was used for the line tracker back in 2011. Can anyone help. We are trying to program it in java to activate a pneumatic pump when there the sensor isn't detecting anything. Can you help? We really need to try to get this done since we are out of time and some other teams are coming to our school to practice. Thanks in advanced!
|
Re: Photo Switch!
What issues are you having? Is it wired correctly? Do you have code problems?
A quick search found a few resources that might help: - http://www.chiefdelphi.com/forums/sh...ad.php?t=89840 - http://www.team2648.com/photoswitches.html - The Netbeans plugin has the 2011 example code. Take a look at these and if you have specific questions, post back and I'll try to help. |
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. |
Re: Photo Switch!
You should replace the line:
if(lightsensor.getAnalogTriggerForRouting() == false) { with if(lightsensor.get() == false) { getAnalogTriggerForRouting() is not what you want to use to get the value of a digital input. The get method returns whether or not it is actually triggered. |
Re: Photo Switch!
Ok thanks! I will try this later on this afternoon and let you know how it works out.
|
Re: Photo Switch!
This didn't work. Is there a different way?
|
| All times are GMT -5. The time now is 10:13. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi