Go to Post The game is going to be exciting. I want a front row seat and a big box of buttered popcorn. - JaneYoung [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 Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #6   Spotlight this post!  
Unread 13-02-2015, 11:02
fireXtract fireXtract is offline
MegaHertz_Lux
FRC #2847 (Mega Hertz)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: fmt
Posts: 42
fireXtract is an unknown quantity at this point
Re: Using Hall Effect Sensors

Now i'm able to get the elevator to stop in response to the hall effect sensor, but once it use it to go up i cant press it to go up again, and if i go down i can only go down once. Pressing the button multiple times to add to count does nothing. What am i missing here?

Code:
package org.usfirst.frc.team2847.robot.commands;

import org.usfirst.frc.team2847.robot.Robot;

import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

/**
 *
 */
public class MagicElevator extends Command {

	int count;
	int tcount;
	double go;
	boolean done;

	public MagicElevator(int setpoint) {
		// Use requires() here to declare subsystem dependencies
		requires(Robot.elevator);
		tcount = setpoint;
	}

	// Called just before this Command runs the first time
	protected void initialize() {
		System.out.println(this);
	}

	// Called repeatedly when this Command is scheduled to run
	protected void execute() {
		count = count + tcount;

		if (count > 0 && Robot.elevator.isHallSet()) {
			count = (count - 1);
		} else if (count < 0 && Robot.elevator.isHallSet()) {
			count = (count + 1);
		}

		if (count >= 1) {
			go = 1;
		} else if (count <= -1) {
			go = -1;
		}
		Robot.elevator.torro(go);

		if (count != 0) {
			done = false;
		} else if (count == 0) {
			done = true;
		}
		tcount = 0;
		SmartDashboard.putNumber("whaeva", count);
		SmartDashboard.putBoolean("hall", Robot.elevator.isHallSet());
	}

	// Make this return true when this Command no longer needs to run execute()
	protected boolean isFinished() {
		SmartDashboard.putNumber("finsishsjdfiaopsdfsa", count);
		return done;
	}

	// Called once after isFinished returns true
	protected void end() {
		Robot.elevator.nothing();
	}

	// Called when another command which requires one or more of the same
	// subsystems is scheduled to run
	protected void interrupted() {
		end();
	}
}

Last edited by fireXtract : 13-02-2015 at 11:37.
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 22:27.

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