Go to Post ChiefDelphi is talking about women's clothing. What a time to be alive. - Karibou [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:49.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi